jekyll-geolexica 1.9.1 → 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/_includes/script.html +17 -2
- data/jekyll-geolexica.gemspec +2 -0
- data/lib/jekyll/geolexica/hooks.rb +35 -0
- data/lib/jekyll/geolexica/version.rb +1 -1
- data/lib/jekyll/geolexica.rb +1 -0
- metadata +30 -2
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
|
data/_includes/script.html
CHANGED
@@ -13,7 +13,22 @@
|
|
13
13
|
};
|
14
14
|
|
15
15
|
var replace_math_symb = function(s){
|
16
|
-
|
16
|
+
// replace mathjax
|
17
|
+
mathjax_containers = s.querySelectorAll('math, mjx-container');
|
18
|
+
|
19
|
+
if(mathjax_containers.length > 0) {
|
20
|
+
s = s.cloneNode(true);
|
21
|
+
s.querySelectorAll('math, mjx-container').forEach(container => {
|
22
|
+
container.replaceWith('<<math_symbol>>');
|
23
|
+
});
|
24
|
+
}
|
25
|
+
|
26
|
+
text = s.innerText;
|
27
|
+
|
28
|
+
// replace asciimath
|
29
|
+
text = text.replace(/(`[^`]+`)/g, '<<math_symbol>>');
|
30
|
+
|
31
|
+
return text;
|
17
32
|
};
|
18
33
|
|
19
34
|
var copyBtn = d.getElementById('engTermCopy');
|
@@ -43,7 +58,7 @@
|
|
43
58
|
for (var _elm of elmsToCopy) {
|
44
59
|
if (_elm.innerText.trim().length > 0) {
|
45
60
|
// textToCopy = textToCopy + _elm.innerText + '\r\n\r\n';
|
46
|
-
textToCopy = textToCopy + replace_math_symb(_elm
|
61
|
+
textToCopy = textToCopy + replace_math_symb(_elm) + '\r\n\r\n';
|
47
62
|
};
|
48
63
|
};
|
49
64
|
|
data/jekyll-geolexica.gemspec
CHANGED
@@ -47,6 +47,8 @@ Gem::Specification.new do |spec|
|
|
47
47
|
# Pin logger to <= 1.5.3 due to incompatibility of logger 1.6.0 with Jekyll 4.3.2
|
48
48
|
spec.add_runtime_dependency "logger", "<= 1.5.3"
|
49
49
|
spec.add_runtime_dependency "relaton"
|
50
|
+
spec.add_runtime_dependency "unitsml"
|
51
|
+
spec.add_runtime_dependency "plurimath"
|
50
52
|
|
51
53
|
# Zeitwerk::Loader#push_dir supports :namespace argument from v. 2.4.
|
52
54
|
spec.add_runtime_dependency "zeitwerk", "~> 2.4"
|
@@ -11,6 +11,7 @@ module Jekyll
|
|
11
11
|
hook :post_read, :site, :load_glossary
|
12
12
|
hook :pre_render, :documents, :expose_glossary
|
13
13
|
hook :pre_render, :pages, :expose_glossary
|
14
|
+
hook :post_render, :pages, :convert_math
|
14
15
|
end
|
15
16
|
|
16
17
|
# Adds Jekyll::Site#glossary method, and initializes an empty glossary.
|
@@ -28,6 +29,40 @@ module Jekyll
|
|
28
29
|
liquid_drop["glossary"] = page_or_document.site.glossary
|
29
30
|
end
|
30
31
|
|
32
|
+
def convert_math(page)
|
33
|
+
prefix_hash = {
|
34
|
+
asciimath: "stem",
|
35
|
+
latex: "latexmath",
|
36
|
+
}
|
37
|
+
|
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]
|
41
|
+
|
42
|
+
mathml_equation = ::Plurimath::Math
|
43
|
+
.parse(ascii_equation, math_notation)
|
44
|
+
.to_mathml
|
45
|
+
|
46
|
+
normalize_mathml(mathml_equation, page.html?)
|
47
|
+
end
|
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
|
64
|
+
end
|
65
|
+
|
31
66
|
def hook event, target, action
|
32
67
|
Jekyll::Hooks.register target, event, &method(action)
|
33
68
|
end
|
data/lib/jekyll/geolexica.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-geolexica
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: glossarist
|
@@ -106,6 +106,34 @@ dependencies:
|
|
106
106
|
- - ">="
|
107
107
|
- !ruby/object:Gem::Version
|
108
108
|
version: '0'
|
109
|
+
- !ruby/object:Gem::Dependency
|
110
|
+
name: unitsml
|
111
|
+
requirement: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
116
|
+
type: :runtime
|
117
|
+
prerelease: false
|
118
|
+
version_requirements: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
- !ruby/object:Gem::Dependency
|
124
|
+
name: plurimath
|
125
|
+
requirement: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
type: :runtime
|
131
|
+
prerelease: false
|
132
|
+
version_requirements: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
109
137
|
- !ruby/object:Gem::Dependency
|
110
138
|
name: zeitwerk
|
111
139
|
requirement: !ruby/object:Gem::Requirement
|