jekyll-asciimath 1.0.0 → 1.1.0

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: 3e9b8cf3a6a1d6136d911e0bbd9cc4b9447fd332eae240c82696a52ff4941ee2
4
- data.tar.gz: 95b5ffe13981239048b7d323b7897662ee4ddcaa9615e61af460a79714524c11
3
+ metadata.gz: ee69a35a602bc339cc9e640608e09d0fcf5e53232d20f07c28dc5540a69a9161
4
+ data.tar.gz: a9ac991b8cbddf6d39f70afb4815986c8ffefb211f768d2850fa755788aa3ee5
5
5
  SHA512:
6
- metadata.gz: 8100dcec170c83500d3aeff55322701f637f5ee7f2834ab0799cb4bd56c59f685da415f118420fa69b40d87e7758965f1d93e7854fdc7fb34570db3fda211b47
7
- data.tar.gz: bf51be49b8684d3a43a566384f37c55c9bc29ed429d2c3448bac52fe0856385fff6375bbf7930b5782c292dcebf3ef30de6732ed846894576bb4af67f575595b
6
+ metadata.gz: b3fef3cd9c5e855fea865c03b6d2691992808627a3ae18fa7ca3bc15b21e22c9fd77d9315d7630e716c704c5bfdbc07e5de44f802daf595adfad31afa15c2c73
7
+ data.tar.gz: f3a8c317835ec8cfb1d488a0edfc48116ec7d7491a6464a2f01d5f1232f5eac3fc711e5e73c7355403b8ab5f85e0631288bbf079aa82ae0ecd17e886f6de1d30
@@ -1,5 +1,9 @@
1
1
  = Changelog
2
2
 
3
+ == 1.1.0
4
+
5
+ Adds support for MathML as output format.
6
+
3
7
  == 1.0.0
4
8
 
5
9
  The initial version of the plugin.
@@ -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 into HTML,
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jekyll-asciimath'
5
- s.version = '1.0.0'
5
+ s.version = '1.1.0'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -13,25 +13,29 @@ end
13
13
 
14
14
  module Jekyll::AsciiMathFilter
15
15
  def asciimath(input)
16
- delimiter = @context.registers[:site].config['asciimath_delimiter'] || '$$'
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 > 0
21
- pieces = "#{delimiter} #{input} #{delimiter}".scan(asciimath_regex)
22
- parsed_pieces = []
23
-
24
- pieces.each_with_index { |piece, idx|
25
- if idx.odd?
26
- parsed_pieces << AsciiMath.parse(piece).to_html
27
- elsif piece != ' '
28
- parsed_pieces << piece
29
- end
30
- }
31
- return parsed_pieces.join('')
32
- else
33
- return input
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.0.0
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 00:00:00.000000000 Z
11
+ date: 2020-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll