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 +4 -4
- data/lib/asciidoctor-latexmath/renderer.rb +15 -4
- data/lib/asciidoctor-latexmath/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbd7c58fc991a8905b27b73ff5de3cffd102acef4362cc816ef3efdac87cddf9
|
4
|
+
data.tar.gz: e014bba6c3f364fadda330af88d8c18bb80bd090261ab4130676e484a30e18cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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:
|
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(
|
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(
|
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
|