metanorma-standoc 3.0.10 → 3.0.12
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cc58286193e50f5ca184b5d5439465515299913c90f81ee497260d75603a2a8
|
4
|
+
data.tar.gz: ec80b7fb69439a96da2b7ece19695cc613545e118686bb2e915e66484091b020
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d28d1413c425808f0fc2f5e41f7ece023b573c6ca3b776a6199f5b04e1fbe31ad3d07d84560c1d00a8ba599f2b95a585f535f51a696828b22d0204bcc87473ff
|
7
|
+
data.tar.gz: 790a9adb18645e2c52206235753cdd029fb473b28ede08b9deb39cd64f1c31d710744b3508d50bbaf1b24c63679a58af0217f6e9168e94426660043a56d9c94c
|
@@ -159,11 +159,25 @@ module Metanorma
|
|
159
159
|
end
|
160
160
|
end
|
161
161
|
|
162
|
+
# Asciidoc macro, e.g. span:publisher[...
|
163
|
+
ADOC_MACRO_START = '\S+:[^\[\] ]*\['.freeze
|
164
|
+
|
165
|
+
# Replace {{ ... }} with {{ pass:[...]}} to preserve any XML markup
|
166
|
+
# use pass:[...\] if {{}} is already inside an Asciidoc macro
|
162
167
|
def boilerplate_read(file)
|
168
|
+
in_macro = false
|
163
169
|
ret = File.read(file, encoding: "UTF-8")
|
164
|
-
/\.adoc$/.match?(file)
|
165
|
-
|
166
|
-
|
170
|
+
/\.adoc$/.match?(file) or return ret
|
171
|
+
ret.split(/(#{ADOC_MACRO_START}|\])/o).map do |r|
|
172
|
+
if /^#{ADOC_MACRO_START}$/o.match?(r)
|
173
|
+
in_macro = true
|
174
|
+
r
|
175
|
+
else
|
176
|
+
delim = in_macro ? '\]' : "]"
|
177
|
+
in_macro = false
|
178
|
+
r.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/, "pass:[\\1#{delim}")
|
179
|
+
end
|
180
|
+
end.join
|
167
181
|
end
|
168
182
|
|
169
183
|
# If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
|
@@ -4,6 +4,7 @@ module Metanorma
|
|
4
4
|
def textcleanup(result)
|
5
5
|
text = result.flatten.map(&:rstrip) * "\n"
|
6
6
|
text = text.gsub(/(?<!\s)\s+<fn /, "<fn ")
|
7
|
+
#@semantic_headless and return text
|
7
8
|
%w(passthrough passthrough-inline).each do |v|
|
8
9
|
text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
9
10
|
</#{v}>}mx) { @c.decode($1) }
|
@@ -34,7 +35,8 @@ module Metanorma
|
|
34
35
|
out = Metanorma::Utils.line_sanitise(lines)
|
35
36
|
e[:last] or out.pop
|
36
37
|
/\s$/.match?(e[:text][-1]) or out[-1].rstrip!
|
37
|
-
|
38
|
+
# do not accidentally XML tags when inserting text with < back in to doc
|
39
|
+
e[:elem].replace(@c.encode(out.join, :hexadecimal, :basic))
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -73,6 +75,7 @@ module Metanorma
|
|
73
75
|
end
|
74
76
|
|
75
77
|
def smartquotes_cleanup1(xmldoc)
|
78
|
+
# prevent normalising boilerplate text twice
|
76
79
|
uninterrupt_quotes_around_xml(xmldoc)
|
77
80
|
dumb2smart_quotes(xmldoc)
|
78
81
|
end
|
@@ -98,7 +101,7 @@ module Metanorma
|
|
98
101
|
|
99
102
|
IGNORE_QUOTES_ELEMENTS =
|
100
103
|
%w(pre tt sourcecode stem asciimath figure bibdata passthrough
|
101
|
-
identifier metanorma-extension).freeze
|
104
|
+
identifier metanorma-extension boilerplate).freeze
|
102
105
|
|
103
106
|
PRESERVE_LINEBREAK_ELEMENTS =
|
104
107
|
%w(pre sourcecode passthrough metanorma-extension stem).freeze
|
@@ -41,6 +41,7 @@ module Metanorma
|
|
41
41
|
@embed_id = node.attr("embed_id")
|
42
42
|
@document_scheme = document_scheme(node)
|
43
43
|
@source_linenums = node.attr("source-linenums-option") == "true"
|
44
|
+
@semantic_headless = node.attr("semantic-metadata-headless") == "true"
|
44
45
|
@default_doctype = "standard"
|
45
46
|
end
|
46
47
|
|
@@ -143,7 +143,7 @@ module Metanorma
|
|
143
143
|
def process(parent, target, attrs)
|
144
144
|
format = target || "metanorma"
|
145
145
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
146
|
-
<<~XML
|
146
|
+
<<~XML.strip
|
147
147
|
<passthrough-inline formats="#{format}">#{xml_process(out)}</passthrough-inline>
|
148
148
|
XML
|
149
149
|
end
|