metanorma-standoc 3.0.12 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cc58286193e50f5ca184b5d5439465515299913c90f81ee497260d75603a2a8
4
- data.tar.gz: ec80b7fb69439a96da2b7ece19695cc613545e118686bb2e915e66484091b020
3
+ metadata.gz: fc20406485170bc7733b681fff936b12da4ef7c535f64501a83eda49d577f606
4
+ data.tar.gz: 0b598e8a7dc1e238419bc5c08764041b96678a457850e68e387bf5b6757e6974
5
5
  SHA512:
6
- metadata.gz: d28d1413c425808f0fc2f5e41f7ece023b573c6ca3b776a6199f5b04e1fbe31ad3d07d84560c1d00a8ba599f2b95a585f535f51a696828b22d0204bcc87473ff
7
- data.tar.gz: 790a9adb18645e2c52206235753cdd029fb473b28ede08b9deb39cd64f1c31d710744b3508d50bbaf1b24c63679a58af0217f6e9168e94426660043a56d9c94c
6
+ metadata.gz: 758c16f43d1bb63d6643366ebae9869c22ded47e63bb43071bd0a3f3310a8906e178b2529d92ac40a193fdcf6d5895d67452bff818ce8454400858db15ea1c48
7
+ data.tar.gz: e3966e963e6a9e0b1d112fca22db3155d73ee3edfe56a2af7274e4be134200b091679b2847d90cb6955c9a453d08d80478c58b2fb8272c088aa7f36607ecc1cd
@@ -65,6 +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
69
  termdef_boilerplate_cleanup(xmldoc)
69
70
  termdef_boilerplate_insert(xmldoc, isodoc)
70
71
  unwrap_boilerplate_clauses(xmldoc, self.class::TERM_CLAUSE)
@@ -75,6 +76,19 @@ module Metanorma
75
76
  initial_boilerplate(xmldoc, isodoc)
76
77
  end
77
78
 
79
+ # KILL
80
+ # escape < > & to > etc,
81
+ # for passthrough insertion into boilerplate
82
+ def boilerplate_isodoc_values(isodoc)
83
+ isodoc.meta.get.each do |k, v|
84
+ if v.is_a?(String)
85
+ isodoc.meta.set(k, v.gsub("&", "&&&&&&&")
86
+ .gsub("<", "<").gsub(">", ">")
87
+ .gsub("&&&&&&&", "&"))
88
+ end
89
+ end
90
+ end
91
+
78
92
  def initial_boilerplate(xml, isodoc)
79
93
  xml.at("//boilerplate") and return
80
94
  preface = xml.at("//preface | //sections | //annex | //references") or
@@ -111,6 +125,7 @@ module Metanorma
111
125
  end
112
126
 
113
127
  b = conv.populate_template(boilerplate_read(filename), nil)
128
+ .gsub(/pass-format:metanorma\[\+\+\+\+\]\s*/, "")
114
129
  boilerplate_file_convert(b)
115
130
  end
116
131
 
@@ -159,23 +174,24 @@ module Metanorma
159
174
  end
160
175
  end
161
176
 
162
- # Asciidoc macro, e.g. span:publisher[...
163
- ADOC_MACRO_START = '\S+:[^\[\] ]*\['.freeze
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
164
181
 
165
182
  # Replace {{ ... }} with {{ pass:[...]}} to preserve any XML markup
166
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}}]
167
186
  def boilerplate_read(file)
168
- in_macro = false
169
187
  ret = File.read(file, encoding: "UTF-8")
170
188
  /\.adoc$/.match?(file) or return ret
171
189
  ret.split(/(#{ADOC_MACRO_START}|\])/o).map do |r|
172
190
  if /^#{ADOC_MACRO_START}$/o.match?(r)
173
- in_macro = true
174
191
  r
175
192
  else
176
- delim = in_macro ? '\]' : "]"
177
- in_macro = false
178
- r.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/, "pass:[\\1#{delim}")
193
+ r.gsub(/(?<!\{)(\{\{[^{}]+\}\})(?!\})/,
194
+ "pass-format:metanorma[++\\1++]")
179
195
  end
180
196
  end.join
181
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
- doc.xpath("//passthrough[@formats = 'metanorma']").each do |p|
169
- p.replace(p.children)
170
- end
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
- %w(passthrough passthrough-inline).each do |v|
9
- text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
10
- </#{v}>}mx) { @c.decode($1) }
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
 
@@ -14,7 +14,6 @@ module Metanorma
14
14
  end
15
15
 
16
16
  def pass(node)
17
- require "debug"; binding.b
18
17
  "<passthrough-inline formats='metanorma'>#{node.content}</passthrough-inline>"
19
18
  end
20
19
 
@@ -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) ? pass_convert(x) : yield(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:") and t = inlinelink(t)
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.sub(/^pass:\[(.+)$/, "pass-format:metanorma[\\1")
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 :text
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"]).convert
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(/(<[^>]*>|&lt;[^&]*&gt;|&[^;]*;)/)
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&#x200c;")
161
+ #segment.gsub(/([[:punct:]])/, "\\1&#x200c;")
162
+ segment
160
163
  else # XML tag or escape
161
164
  segment
162
165
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "3.0.12".freeze
22
+ VERSION = "3.0.14".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.12
4
+ version: 3.0.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.