jekyll-asciimath 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +4 -0
- data/README.adoc +41 -2
- data/jekyll-asciimath.gemspec +1 -1
- data/lib/jekyll_asciimath/jekyll_asciimath.rb +20 -16
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee69a35a602bc339cc9e640608e09d0fcf5e53232d20f07c28dc5540a69a9161
|
4
|
+
data.tar.gz: a9ac991b8cbddf6d39f70afb4815986c8ffefb211f768d2850fa755788aa3ee5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3fef3cd9c5e855fea865c03b6d2691992808627a3ae18fa7ca3bc15b21e22c9fd77d9315d7630e716c704c5bfdbc07e5de44f802daf595adfad31afa15c2c73
|
7
|
+
data.tar.gz: f3a8c317835ec8cfb1d488a0edfc48116ec7d7491a6464a2f01d5f1232f5eac3fc711e5e73c7355403b8ab5f85e0631288bbf079aa82ae0ecd17e886f6de1d30
|
data/CHANGELOG.adoc
CHANGED
data/README.adoc
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
== `asciimath` filter
|
4
4
|
|
5
5
|
When applied to a variable, replaces AsciiMath markup between specified delimiters
|
6
|
-
with HTML.
|
6
|
+
with MathML or HTML.
|
7
7
|
|
8
8
|
For example, Liquid markup like this:
|
9
9
|
|
@@ -16,6 +16,25 @@ For example, Liquid markup like this:
|
|
16
16
|
would be rendered into this
|
17
17
|
(but without whitespace, which is added for legibility):
|
18
18
|
|
19
|
+
MathML:
|
20
|
+
|
21
|
+
[source,html]
|
22
|
+
--
|
23
|
+
<math>
|
24
|
+
<mi>m</mi>
|
25
|
+
</math>
|
26
|
+
|
27
|
+
out of
|
28
|
+
|
29
|
+
<math>
|
30
|
+
<mi>n</mi>
|
31
|
+
</math>
|
32
|
+
|
33
|
+
redundancy
|
34
|
+
--
|
35
|
+
|
36
|
+
HTML:
|
37
|
+
|
19
38
|
[source,html]
|
20
39
|
--
|
21
40
|
<span class="math-inline">
|
@@ -37,7 +56,8 @@ redundancy
|
|
37
56
|
|
38
57
|
== How it works
|
39
58
|
|
40
|
-
This plugin uses https://github.com/asciidoctor/asciimath for converting AsciiMath
|
59
|
+
This plugin uses https://github.com/asciidoctor/asciimath for converting AsciiMath
|
60
|
+
into MathML and HTML,
|
41
61
|
and a crude regular expression for extracting AsciiMath markup from a mass of text
|
42
62
|
based on delimiters.
|
43
63
|
|
@@ -47,6 +67,25 @@ The plugin will work without any site configuration keys,
|
|
47
67
|
but it requires you to include AsciiMath styling CSS in your template
|
48
68
|
and to pay attention to the default delimiter setting (see below).
|
49
69
|
|
70
|
+
=== Output format
|
71
|
+
|
72
|
+
Depending on the browsers you intend to support, you may choose
|
73
|
+
MathML or HTML as the output format. Native MathML support is available
|
74
|
+
for most browsers, except MSIE.
|
75
|
+
|
76
|
+
Configure the delimiter for use with `asciimath` filters in your site config
|
77
|
+
as follows:
|
78
|
+
|
79
|
+
[source,yaml]
|
80
|
+
--
|
81
|
+
asciimath_output_format: mathml
|
82
|
+
--
|
83
|
+
|
84
|
+
Valid choices: `mathml` (default), `html`.
|
85
|
+
|
86
|
+
For best rendering results, choose `mathml`.
|
87
|
+
|
88
|
+
|
50
89
|
=== Delimiter
|
51
90
|
|
52
91
|
Currently, only one delimiter is supported
|
data/jekyll-asciimath.gemspec
CHANGED
@@ -13,25 +13,29 @@ end
|
|
13
13
|
|
14
14
|
module Jekyll::AsciiMathFilter
|
15
15
|
def asciimath(input)
|
16
|
-
|
16
|
+
site_config = @context.registers[:site].config
|
17
|
+
|
18
|
+
delimiter = site_config['asciimath_delimiter'] || '$$'
|
19
|
+
output_format = site_config['asciimath_output_format']
|
20
|
+
output_format = 'mathml' unless %w(html mathml).include?(output_format)
|
21
|
+
|
17
22
|
delim_regex = Regexp.quote(delimiter)
|
18
23
|
asciimath_regex = Regexp.new("(?<=#{delim_regex})[^#{delim_regex}]+(?=#{delim_regex})")
|
19
24
|
|
20
|
-
if input.scan(asciimath_regex).size
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
25
|
+
return input if input.scan(asciimath_regex).size == 0
|
26
|
+
|
27
|
+
pieces = "#{delimiter} #{input} #{delimiter}".scan(asciimath_regex)
|
28
|
+
parsed_pieces = []
|
29
|
+
|
30
|
+
pieces.each_with_index { |piece, idx|
|
31
|
+
if idx.odd?
|
32
|
+
parsed_pieces << AsciiMath.parse(piece).send("to_#{output_format}")
|
33
|
+
elsif piece != ' '
|
34
|
+
parsed_pieces << piece
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
parsed_pieces.join('')
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-asciimath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|