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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9bd91cb309055026c71c87645e7196ff3d4b3116de988a8499ef49805b6f72b
4
- data.tar.gz: 6c2a5bebd531945f9d75f9e7c64e515b6292fd488b81a157421aa4852e62cb15
3
+ metadata.gz: ee23d497ac69847ec48653b2b425d90b7b9f592579a8f830084d18a4ef4dcd25
4
+ data.tar.gz: 733a951d6026cab7bc0605cadbcb0e89dd15821e9bd7e25410d8b212e7a84ebc
5
5
  SHA512:
6
- metadata.gz: e90fb75be8eb7f4b77ea2cd5801da1e3678c43837686130ddecce1917a7a8b23596574d973f5d8795a899562e3eab91407c520fda05492d39288fd3d60d2c480
7
- data.tar.gz: 55b7408414a081804d8c2f6b988f79a21f7ced484a8acc4fb57d29cb762b1e043459a25545a10bbb4e2f90b2250a7312fa677ff9baf0e3cd799b4597f522d54d
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
- page.output.gsub!(/stem:\[([^\]]*?)\]/) do
34
- ascii_equation = CGI.unescapeHTML(Regexp.last_match[1])
33
+ prefix_hash = {
34
+ asciimath: "stem",
35
+ latex: "latexmath",
36
+ }
35
37
 
36
- mathml_equation = ::Plurimath::Math
37
- .parse(ascii_equation, :asciimath)
38
- .to_mathml
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
- # temporary hack to use display inline for math equations because
41
- # currently there is no option to use display inline in plurimath
42
- mathml_equation.gsub!("display=\"block\"", "display=\"inline\"")
42
+ mathml_equation = ::Plurimath::Math
43
+ .parse(ascii_equation, math_notation)
44
+ .to_mathml
43
45
 
44
- # Removing newlines(\n) and escaping double quotes(")
45
- # because they will cause parsing issues in json
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
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Jekyll
5
5
  module Geolexica
6
- VERSION = "1.9.2".freeze
6
+ VERSION = "1.9.3".freeze
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-geolexica
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.2
4
+ version: 1.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.