metanorma-standoc 3.0.13 → 3.0.14
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/metanorma/standoc/cleanup_boilerplate.rb +11 -8
- data/lib/metanorma/standoc/cleanup_inline.rb +4 -3
- data/lib/metanorma/standoc/cleanup_text.rb +4 -4
- data/lib/metanorma/standoc/inline.rb +0 -1
- data/lib/metanorma/standoc/macros.rb +14 -3
- data/lib/metanorma/standoc/macros_inline.rb +6 -3
- data/lib/metanorma/standoc/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: fc20406485170bc7733b681fff936b12da4ef7c535f64501a83eda49d577f606
|
4
|
+
data.tar.gz: 0b598e8a7dc1e238419bc5c08764041b96678a457850e68e387bf5b6757e6974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 758c16f43d1bb63d6643366ebae9869c22ded47e63bb43071bd0a3f3310a8906e178b2529d92ac40a193fdcf6d5895d67452bff818ce8454400858db15ea1c48
|
7
|
+
data.tar.gz: e3966e963e6a9e0b1d112fca22db3155d73ee3edfe56a2af7274e4be134200b091679b2847d90cb6955c9a453d08d80478c58b2fb8272c088aa7f36607ecc1cd
|
@@ -65,7 +65,7 @@ module Metanorma
|
|
65
65
|
|
66
66
|
def boilerplate_cleanup(xmldoc)
|
67
67
|
isodoc = boilerplate_isodoc(xmldoc) or return
|
68
|
-
boilerplate_isodoc_values(isodoc)
|
68
|
+
# boilerplate_isodoc_values(isodoc)
|
69
69
|
termdef_boilerplate_cleanup(xmldoc)
|
70
70
|
termdef_boilerplate_insert(xmldoc, isodoc)
|
71
71
|
unwrap_boilerplate_clauses(xmldoc, self.class::TERM_CLAUSE)
|
@@ -76,6 +76,7 @@ module Metanorma
|
|
76
76
|
initial_boilerplate(xmldoc, isodoc)
|
77
77
|
end
|
78
78
|
|
79
|
+
# KILL
|
79
80
|
# escape < > & to &gt; etc,
|
80
81
|
# for passthrough insertion into boilerplate
|
81
82
|
def boilerplate_isodoc_values(isodoc)
|
@@ -124,6 +125,7 @@ module Metanorma
|
|
124
125
|
end
|
125
126
|
|
126
127
|
b = conv.populate_template(boilerplate_read(filename), nil)
|
128
|
+
.gsub(/pass-format:metanorma\[\+\+\+\+\]\s*/, "")
|
127
129
|
boilerplate_file_convert(b)
|
128
130
|
end
|
129
131
|
|
@@ -172,23 +174,24 @@ module Metanorma
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
|
-
# Asciidoc macro, e.g. span:publisher[...
|
176
|
-
|
177
|
+
# Asciidoc macro, e.g. span:publisher[...]
|
178
|
+
# May contain one or more {{ }} in target, with spaces in them
|
179
|
+
# Does not end in \]
|
180
|
+
ADOC_MACRO_START = '\S+:(?:[^\[\] ]+|\{\{[^{}]+\}\})*\[.*?(?<!\\\\)\]'.freeze
|
177
181
|
|
178
182
|
# Replace {{ ... }} with {{ pass:[...]}} to preserve any XML markup
|
179
183
|
# use pass:[...\] if {{}} is already inside an Asciidoc macro
|
184
|
+
# Do not use pass: if this is a macro target: mailto:{{x}}[]
|
185
|
+
# or body: mailto:[{{x}}]
|
180
186
|
def boilerplate_read(file)
|
181
|
-
in_macro = false
|
182
187
|
ret = File.read(file, encoding: "UTF-8")
|
183
188
|
/\.adoc$/.match?(file) or return ret
|
184
189
|
ret.split(/(#{ADOC_MACRO_START}|\])/o).map do |r|
|
185
190
|
if /^#{ADOC_MACRO_START}$/o.match?(r)
|
186
|
-
in_macro = true
|
187
191
|
r
|
188
192
|
else
|
189
|
-
|
190
|
-
|
191
|
-
r.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/, "pass:[\\1#{delim}")
|
193
|
+
r.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/,
|
194
|
+
"pass-format:metanorma[++\\1++]")
|
192
195
|
end
|
193
196
|
end.join
|
194
197
|
end
|
@@ -164,10 +164,11 @@ module Metanorma
|
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
167
|
+
# overwrite xmldoc, so must assign result to xmldoc
|
167
168
|
def passthrough_metanorma_cleanup(doc)
|
168
|
-
|
169
|
-
|
170
|
-
|
169
|
+
ret = to_xml(doc)
|
170
|
+
.gsub(%r{<passthrough formats="metanorma">([^<]*)</passthrough>}) { @c.decode($1) }
|
171
|
+
doc.root = Nokogiri::XML(ret, &:huge).root
|
171
172
|
end
|
172
173
|
|
173
174
|
def link_cleanup(xmldoc)
|
@@ -5,10 +5,10 @@ module Metanorma
|
|
5
5
|
text = result.flatten.map(&:rstrip) * "\n"
|
6
6
|
text = text.gsub(/(?<!\s)\s+<fn /, "<fn ")
|
7
7
|
#@semantic_headless and return text
|
8
|
-
|
9
|
-
text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
10
|
-
|
11
|
-
end
|
8
|
+
#%w(passthrough passthrough-inline).each do |v|
|
9
|
+
#text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
10
|
+
#</#{v}>}mx) { @c.decode($1) }
|
11
|
+
#end
|
12
12
|
text
|
13
13
|
end
|
14
14
|
|
@@ -120,10 +120,11 @@ module Metanorma
|
|
120
120
|
|
121
121
|
def pass_inline_split(text)
|
122
122
|
text.split(PASS_INLINE_MACRO_RX).each.map do |x|
|
123
|
-
PASS_INLINE_MACRO_RX.match?(x) ?
|
123
|
+
PASS_INLINE_MACRO_RX.match?(x) ? x : yield(x)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
# KILL
|
127
128
|
def pass_convert(text)
|
128
129
|
text.sub(/^pass:\[(.+)$/, "pass-format:metanorma[\\1")
|
129
130
|
end
|
@@ -209,7 +210,8 @@ module Metanorma
|
|
209
210
|
p = Metanorma::Utils::LineStatus.new
|
210
211
|
lines = reader.lines.map do |t|
|
211
212
|
p.process(t)
|
212
|
-
!p.pass && t.include?("pass:")
|
213
|
+
!p.pass && (t.include?("pass:") || t.include?("pass-format:")) and
|
214
|
+
t = inlinelink(t)
|
213
215
|
t
|
214
216
|
end
|
215
217
|
::Asciidoctor::PreprocessorReader.new document, lines
|
@@ -221,8 +223,17 @@ module Metanorma
|
|
221
223
|
end
|
222
224
|
end
|
223
225
|
|
226
|
+
# pass:[A] => pass-format:metanorma[++A++],
|
227
|
+
# so long as A doesn't already start with ++
|
228
|
+
# ditto pass-format:[A] => pass-format:[++A++]
|
224
229
|
def pass_convert(text)
|
225
|
-
text
|
230
|
+
text
|
231
|
+
.gsub(/pass-format:([^\[ ]*)\[(?!\+\+)(.+?)(?<!\\)\]/,
|
232
|
+
"pass-format:\\1[++\\2++]")
|
233
|
+
.gsub(/pass:\[(?=\+\+)(.+?)(?<!\\)\]/,
|
234
|
+
"pass-format:metanorma[\\1]")
|
235
|
+
.gsub(/pass:\[(?!\+\+)(.+?)(?<!\\)\]/,
|
236
|
+
"pass-format:metanorma[++\\1++]")
|
226
237
|
end
|
227
238
|
|
228
239
|
def inlinelink(text)
|
@@ -138,16 +138,18 @@ module Metanorma
|
|
138
138
|
class PassFormatInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
139
139
|
use_dsl
|
140
140
|
named :"pass-format"
|
141
|
-
parse_content_as :
|
141
|
+
parse_content_as :raw
|
142
142
|
|
143
143
|
def process(parent, target, attrs)
|
144
144
|
format = target || "metanorma"
|
145
|
-
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]
|
145
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"],
|
146
|
+
type: :pass, attributes: { 'subs' => [] }).convert
|
146
147
|
<<~XML.strip
|
147
148
|
<passthrough-inline formats="#{format}">#{xml_process(out)}</passthrough-inline>
|
148
149
|
XML
|
149
150
|
end
|
150
151
|
|
152
|
+
# KILL
|
151
153
|
# Split content into XML tags (including XML-escaped instances),
|
152
154
|
# XML escapes, and text segments
|
153
155
|
# Then only apply ZWNJ to punctuation in text segments
|
@@ -156,7 +158,8 @@ module Metanorma
|
|
156
158
|
segments = out.split(/(<[^>]*>|<[^&]*>|&[^;]*;)/)
|
157
159
|
segments.each_with_index do |segment, index|
|
158
160
|
processed_out += if index.even? # Text segment (not a tag or escape)
|
159
|
-
segment.gsub(/([[:punct:]])/, "\\1‌")
|
161
|
+
#segment.gsub(/([[:punct:]])/, "\\1‌")
|
162
|
+
segment
|
160
163
|
else # XML tag or escape
|
161
164
|
segment
|
162
165
|
end
|