asciidoctor-latexmath 1.0.0.beta.1 → 1.0.0.beta.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ca8d29951cb49e8f03c90d0164ea0de948ebfe27c3b8b0eaba5680854c882ab
4
- data.tar.gz: 0475e17a8f13622a77f76a54172318c92e4020060477670e12561f32c4c1e520
3
+ metadata.gz: cbd7c58fc991a8905b27b73ff5de3cffd102acef4362cc816ef3efdac87cddf9
4
+ data.tar.gz: e014bba6c3f364fadda330af88d8c18bb80bd090261ab4130676e484a30e18cc
5
5
  SHA512:
6
- metadata.gz: 0e9cc6043e7514fc9696ad22bc04ef3a7d4b62fd7577ce430cc9b3f7b67767687ffe179bd5a16c6edb89c030829ca0a9f637fb7bff1a11dc91a7aac94d9c7cc1
7
- data.tar.gz: a29f598839324003635ab00432a19edfe798478258c79d89c9347447a71db6c37e4b1ad68fd074bb7524f680e0247deea87ba8923c98a5100c94ede420cba566
6
+ metadata.gz: 71df15fbadccafd57d77f0488da9d8c2b5ed9b2504394c2a36d73979b30c7edac3be8e13c7cc3535e928dd2900d59cddd8b429fcff4ddd5ff106c3f45a5ebf41
7
+ data.tar.gz: 7fb1d2e784ae30690e0909bc5c51ee011d401acda4f36f6fa82cbfe8233c24956156b73f85e59f23ffbabdfd85654aa134f288ea40ec16b55e1e951572808d87
@@ -11,6 +11,7 @@ require "shellwords"
11
11
  require "digest"
12
12
  require "pathname"
13
13
  require "json"
14
+ require "cgi"
14
15
  require "asciidoctor"
15
16
 
16
17
  module Asciidoctor
@@ -56,15 +57,16 @@ module Asciidoctor
56
57
  end
57
58
 
58
59
  def render(equation:, display:, inline: false, id: nil, asciidoc_source: nil, source_location: nil)
59
- basename = sanitize_basename(id) || auto_basename(equation)
60
+ normalized_equation = normalize_equation(equation)
61
+ basename = sanitize_basename(id) || auto_basename(normalized_equation)
60
62
  inline_embed = inline && @inline_attribute
61
63
  signature = cache_signature(
62
- equation: equation,
64
+ equation: normalized_equation,
63
65
  display: display,
64
66
  inline: inline,
65
67
  inline_embed: inline_embed
66
68
  )
67
- equation_digest = Digest::SHA256.hexdigest(equation)
69
+ equation_digest = Digest::SHA256.hexdigest(normalized_equation)
68
70
 
69
71
  if @cache_enabled
70
72
  if (cached = load_cached_render(basename, signature, equation_digest, inline_embed))
@@ -78,7 +80,7 @@ module Asciidoctor
78
80
  tex_path = File.join(dir, "#{basename}.tex")
79
81
  pdf_path = File.join(dir, "#{basename}.pdf")
80
82
 
81
- latex_source = build_document(equation, display)
83
+ latex_source = build_document(normalized_equation, display)
82
84
  File.write(tex_path, latex_source)
83
85
  begin
84
86
  run_pdflatex(
@@ -510,6 +512,15 @@ module Asciidoctor
510
512
  def latex_environment?(equation)
511
513
  equation.match?(/\\begin\s*\{[^}]+\}/) && equation.match?(/\\end\s*\{[^}]+\}/)
512
514
  end
515
+
516
+ def normalize_equation(equation)
517
+ return "" if equation.nil?
518
+
519
+ stripped = equation.to_s.strip
520
+ return "" if stripped.empty?
521
+
522
+ CGI.unescapeHTML(stripped).tr("\u00A0", " ")
523
+ end
513
524
  end
514
525
  end
515
526
  end
@@ -6,6 +6,6 @@
6
6
 
7
7
  module Asciidoctor
8
8
  module Latexmath
9
- VERSION = "1.0.0.beta.1"
9
+ VERSION = "1.0.0.beta.2"
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-latexmath
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.beta.1
4
+ version: 1.0.0.beta.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shuai Zhang