jekyll-geolexica 1.9.2 → 1.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/geolexica/hooks.rb +27 -13
- data/lib/jekyll/geolexica/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee23d497ac69847ec48653b2b425d90b7b9f592579a8f830084d18a4ef4dcd25
|
4
|
+
data.tar.gz: 733a951d6026cab7bc0605cadbcb0e89dd15821e9bd7e25410d8b212e7a84ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1083c0633e7c3c50ca6b907c1b07783cee3707cb5627f32fc85bd7da17903c12bcbd811610a090c99eb6ec34a81a917cd21f1ff32d02991ac290ccf2b0f1777
|
7
|
+
data.tar.gz: ac7b703a022b68aff69ae3ab9bcd56acdb2b3ec182ce40861a0b4325f972de231e1e2ada3a4808817260b3a0024f9854d5edb649e62fb69b9aac1033f53e0e1a
|
@@ -30,23 +30,37 @@ module Jekyll
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def convert_math(page)
|
33
|
-
|
34
|
-
|
33
|
+
prefix_hash = {
|
34
|
+
asciimath: "stem",
|
35
|
+
latex: "latexmath",
|
36
|
+
}
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
38
|
+
prefix_hash.each do |math_notation, prefix|
|
39
|
+
page.output.gsub!(/#{prefix}:(?<re>\[((?>[^\[\]]+)|\g<re>)*\])/) do
|
40
|
+
ascii_equation = CGI.unescapeHTML(Regexp.last_match[1])[1..-2]
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
|
42
|
+
mathml_equation = ::Plurimath::Math
|
43
|
+
.parse(ascii_equation, math_notation)
|
44
|
+
.to_mathml
|
43
45
|
|
44
|
-
|
45
|
-
|
46
|
-
mathml_equation.gsub!("\n", "").gsub!("\"", "\\\"") unless page.html?
|
47
|
-
|
48
|
-
mathml_equation
|
46
|
+
normalize_mathml(mathml_equation, page.html?)
|
47
|
+
end
|
49
48
|
end
|
49
|
+
rescue => e
|
50
|
+
# Skipping broken formulas
|
51
|
+
Jekyll.logger.info(e.message)
|
52
|
+
end
|
53
|
+
|
54
|
+
def normalize_mathml(mathml_equation, is_html)
|
55
|
+
# temporary hack to use display inline for math equations because
|
56
|
+
# currently there is no option to use display inline in plurimath
|
57
|
+
mathml_equation = mathml_equation.gsub("display=\"block\"", "display=\"inline\"")
|
58
|
+
|
59
|
+
# Removing newlines(\n) and escaping double quotes(")
|
60
|
+
# because they will cause parsing issues in json
|
61
|
+
mathml_equation = mathml_equation.gsub("\n", "").gsub("\"", "\\\"") unless is_html
|
62
|
+
|
63
|
+
mathml_equation
|
50
64
|
end
|
51
65
|
|
52
66
|
def hook event, target, action
|