Sha256: 6c41b872070a9a9474b9dcbd63ea5d2032226e3b0e3975527519178dc92ea69b
Contents?: true
Size: 795 Bytes
Versions: 6
Compression:
Stored size: 795 Bytes
Contents
# TEX_DOLLAR_SUB = '\1latexmath:[\2]\3' module Transform # Map $...$ to stem:[...] # Map $...$ to \( ... \) TEX_DOLLAR_RX = /(^|\s|\()\$(.*?)\$($|\s|\)|,|\.)/ TEX_DOLLAR_SUB = '\1\\\(\2\\\)\3' TEX_DOLLAR_SUB2 = '\1latexmath:[\2]\3' $fixmath = lambda { |x| x.gsub TEX_DOLLAR_RX, TEX_DOLLAR_SUB } $fixmath2 = lambda { |x| x.gsub TEX_DOLLAR_RX, TEX_DOLLAR_SUB2 } $identity = lambda { |x| x } def self.read_string in_file return File.open(in_file, 'r') { |f| f.read } end def self.map_string str, transformer return transformer.call str end def self.map_file in_file, out_file, transform_string input = File.open(in_file, 'r') { |f| f.read } output = transform_string.call(input) File.open(out_file, 'w' ) { |f| f.write output } end end
Version data entries
6 entries across 3 versions & 1 rubygems