Sha256: 83e8f53782581e12adff23983593c6fe5e2eaf469924255af23f303dd7840706
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
Contents
module MathToItex class Parser # https://stackoverflow.com/questions/14182879/regex-to-match-latex-equations REGEX = / (?<!\\) # negative look-behind to make sure start is not escaped (?: # start non-capture group for all possible match starts # group 1, match dollar signs only # single or double dollar sign enforced by look-arounds ((?<!\$)\${1,2}(?!\$))| # group 2, match escaped parenthesis (\\\()| # group 3, match escaped bracket (\\\[)| # group 4, match begin equation (\\begin\{equation\}) ) (.*?(\g<1>)?.*?) # match everything in between including nested LaTeX equations (?<!\\) # negative look-behind to make sure end is not escaped # if group 1 was start, match \1 (?(1)(?<!\$)\1(?!\$)| # if group 2 was start, escaped parenthesis is end (?(2)\\\)| # if group 3 was start, escaped bracket is end (?(3)\\\]| # otherwise group 4 was start, match end equation \\end\{equation\} ))) /xm end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
math-to-itex-0.3.0 | lib/math-to-itex/parser.rb |