20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/latexmath/tokenizer.rb', line 20
def fetch_token
skip(/\s+/)
skip(/\$\$/)
token = if scan(/\\mathbb\{[^}]+}/)
if Latexmath::Symbol.get(matched)
"&#x#{Latexmath::Symbol.get(matched)};"
else
matched
end
elsif scan(/{\\bf [^}]+}/)
matches = matched.match(/{\\bf ([^}]+)}/)
symbol = Latexmath::Symbol.get("\\mathbf{#{matches[1]}}")
"&#x#{symbol};" if symbol
elsif scan(/\\\\\[\d+mm\]/)
'\\\\' elsif scan(/\\mbox{[^\}]+}/)
matched
elsif scan(/\\Delta/)
matched
elsif scan(/\\vec{[^\}]+}/)
matched
elsif scan(/\\hat{[^\}]+}/)
matched
elsif scan(/\\textrm{[^\}]+}/)
matched
elsif scan(/{\\rm [^}]+}/)
matches = matched.match(/{\\rm ([^}]+)}/)
matches[1]
elsif scan(/\\[a-z]+\{(bmatrix|Bmatrix|matrix|vmatrix|Vmatrix|array|pmatrix|split)\*?\}/)
matched
elsif scan(/\\[a-z]+/)
matched
elsif scan(/\\\\/)
matched
elsif scan(/\\\[/)
matched
elsif scan(/\\\]/)
matched
elsif scan(/\\\{/)
matched
elsif scan(/\\[:;,]/)
matched
elsif scan(/\\/)
matched
elsif scan(/[a-z]/)
matched
elsif scan(/[0-9]+\.[0-9]+/)
matched
elsif scan(/[0-9]+/)
matched
elsif scan(/ /)
matched
elsif scan(/[\{\}\*]/)
matched
elsif scan(/./)
matched
end
token
end
|