metanorma-standoc 2.9.3 → 2.9.4

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: e946ea4ef470077763b56b2435a231a884ddede3c32f9bd09dde4fd912b15bfc
4
- data.tar.gz: 80511a11e935c1e090be377db8180907835895d5507e8b4e88df6c2dee7d4f9a
3
+ metadata.gz: 49c6dfeea46b38b2e162f13b0e5b8f1e57f446c433e2e30313fff2e4c5b4e96e
4
+ data.tar.gz: 188590c9c73a87e1ba73322a540986836b256541764ef4e45ba1a1a134eda1df
5
5
  SHA512:
6
- metadata.gz: a72d55869cbd272db4c6818cd8aadd3057021bf4b876c595ecb6c10d98008c7da98368189df23ad25297eaa68119c2c2cdc3efeb9b573812b9a200974458d703
7
- data.tar.gz: 6710ac348b46e662a77ec202ec26944c3d0956a5b984546995444f352f661fefff3995c328ee6c7b2448137d690a7091db2b873584a277279f1c01e549c8a099
6
+ metadata.gz: cc6aed2b8ca43330882c41c8a00e2bc679ff5de30e9c1f914eca253ecc7900368b4c1968a2dbeceeae9db025798a15fe73a68892d83c4c0dcc6080477e66327a
7
+ data.tar.gz: 0bf3a151f8dd22a2c28ee6ed158df5f8d8c6f2afe0d27cad2d8ec3234746d1994354ab52dbd1735b8c54ab99e44c3d3b7b10249a464205fc29c453d996e377c9
@@ -229,6 +229,46 @@ h6:hover > a.anchor,
229
229
  .inline-header:hover > a.anchor {
230
230
  visibility: visible; }
231
231
 
232
+ /* collapsible snippets: collapsible before hidable */
233
+ .hidable {
234
+ max-height: 0;
235
+ overflow: hidden;
236
+ transition: max-height 0.2s ease-out; }
237
+
238
+ .collapsible {
239
+ background-color: #777;
240
+ color: white;
241
+ cursor: pointer;
242
+ padding: 12px 0;
243
+ margin: 0;
244
+ width: 100%;
245
+ border: none;
246
+ text-align: left;
247
+ outline: none;
248
+ font-size: 15px; }
249
+
250
+ .active, .collapsible:hover {
251
+ background-color: #555; }
252
+
253
+ .collapsible:after {
254
+ content: '\25bc';
255
+ color: white;
256
+ font-weight: bold;
257
+ float: right;
258
+ margin-left: 12px;
259
+ margin-right: 12px; }
260
+
261
+ .active:after {
262
+ content: "\25b2"; }
263
+
264
+ /* collapsible: */
265
+ .collapsible + .hidable {
266
+ margin-top: 0; }
267
+
268
+ .collapsible:not(.active) + .hidable {
269
+ overflow: hidden;
270
+ padding: 0; }
271
+
232
272
  #brochure-band {
233
273
  background-color: #0AC442; }
234
274
 
@@ -212,7 +212,8 @@ module Metanorma
212
212
  noko do |xml|
213
213
  xml.passthrough **attr_code(formats:
214
214
  node.attr("format") || "metanorma") do |p|
215
- p << @c.encode(@c.decode(node.content), :basic, :hexadecimal)
215
+ # p << @c.encode(@c.decode(node.content), :basic, :hexadecimal)
216
+ p << @c.encode(node.content, :basic, :hexadecimal)
216
217
  end
217
218
  end
218
219
  end
@@ -144,8 +144,7 @@ module Metanorma
144
144
  yaml.is_a?(Hash) && !yaml["contributor"] and yaml = [yaml]
145
145
  yaml.is_a?(Array) and yaml = { "contributor" => yaml }
146
146
  r = yaml2relaton(yaml)
147
- Nokogiri::XML(r).xpath("//contributor").reverse
148
- .each do |c|
147
+ Nokogiri::XML(r).xpath("//contributor").reverse_each do |c|
149
148
  ins.next = c
150
149
  end
151
150
  end
@@ -161,10 +161,12 @@ module Metanorma
161
161
  def datauri_attachment(path, doc)
162
162
  @datauriattachment or return
163
163
  m = add_misc_container(doc)
164
- f = File.basename(path)
165
- d = Vectory::Utils::datauri(path, @localdir)
166
- m << "<attachment name='#{f}'/>"
167
- m.last_element_child << d
164
+ f = File.join(@attachmentsdir, File.basename(path))
165
+ f = Pathname.new(File.expand_path(f))
166
+ .relative_path_from(Pathname.new(File.expand_path(@localdir)))
167
+ e = (m << "<attachment name='#{f}'/>").last_element_child
168
+ Vectory::Utils::datauri(path, @localdir).scan(/.{1,60}/)
169
+ .each { |dd| e << "#{dd}\n" }
168
170
  end
169
171
 
170
172
  def valid_attachment?(path, bib)
@@ -183,8 +185,28 @@ module Metanorma
183
185
  FileUtils.mkdir_p(@attachmentsdir)
184
186
  end
185
187
 
188
+ # remove dupes if both same ID and same docid, in case dupes introduced
189
+ # through termbases
190
+ def remove_dup_bibtem_id(xmldoc)
191
+ bibitem_id_docid_hash(xmldoc).each_value do |v|
192
+ v.each_value do |v1|
193
+ v1[1..].each(&:remove)
194
+ end
195
+ end
196
+ end
197
+
198
+ def bibitem_id_docid_hash(xmldoc)
199
+ xmldoc.xpath("//bibitem[@id]").each_with_object({}) do |b, m|
200
+ m[b["id"]] ||= {}
201
+ docid = b.at("./docidentifier")&.text || "NO ID"
202
+ m[b["id"]][docid] ||= []
203
+ m[b["id"]][docid] << b
204
+ end
205
+ end
206
+
186
207
  def bibitem_cleanup(xmldoc)
187
- bibitem_nested_id(xmldoc)
208
+ bibitem_nested_id(xmldoc) # feeds remove_dup_bibtem_id
209
+ remove_dup_bibtem_id(xmldoc)
188
210
  ref_dl_cleanup(xmldoc)
189
211
  formattedref_spans(xmldoc)
190
212
  fetch_local_bibitem(xmldoc)
@@ -108,6 +108,7 @@ module Metanorma
108
108
  prev = elem.at(".//preceding::text()[1]") or return
109
109
  /\S\Z/.match?(prev.text) or return
110
110
  foll = elem.at(".//following::text()[1]")
111
+ /"$/.match?(prev.text) and /^"/.match?(foll&.text) and return # "<tag/>"
111
112
  m = /\A(["'][[:punct:]]*)(\s|\Z)/
112
113
  .match(@c.decode(foll&.text)) or return
113
114
  foll.content = foll.text.sub(/\A(["'][[:punct:]]*)/, "")
@@ -10,7 +10,7 @@ module Metanorma
10
10
 
11
11
  def toc_cleanup_para(xmldoc)
12
12
  xmldoc.xpath("//p[toc]").each do |x|
13
- x.xpath("./toc").reverse.each do |t|
13
+ x.xpath("./toc").reverse_each do |t|
14
14
  x.next = t
15
15
  end
16
16
  x.remove if x.text.strip.empty?
@@ -29,7 +29,10 @@ module Metanorma
29
29
  inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
30
30
  inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
31
31
  block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
32
+ block_macro Metanorma::Plugin::Lutaml::LutamlEaDiagramBlockMacro
32
33
  block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
34
+ block_macro Metanorma::Plugin::Lutaml::LutamlGmlDictionaryBlockMacro
35
+ block Metanorma::Plugin::Lutaml::LutamlGmlDictionaryBlock
33
36
  preprocessor Metanorma::Standoc::EmbedIncludeProcessor
34
37
  preprocessor Metanorma::Standoc::LinkProtectPreprocessor
35
38
  preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
@@ -21,8 +21,8 @@ module Metanorma
21
21
  def render
22
22
  ERB.new(
23
23
  File.read(
24
- File.join(TEMPLATES_PATH, "plantuml_representation.adoc.erb")
25
- )
24
+ File.join(TEMPLATES_PATH, "plantuml_representation.adoc.erb"),
25
+ ),
26
26
  ).result(binding)
27
27
  end
28
28
 
@@ -46,7 +46,7 @@ module Metanorma
46
46
  '******* CLASS DEFINITIONS ********************************************
47
47
  #{join_as_plantuml(
48
48
  classes_to_classes_plantuml(yml['classes']),
49
- enums_to_enums_plantuml(yml['enums'])
49
+ enums_to_enums_plantuml(yml['enums']),
50
50
  )}
51
51
  TEMPLATE
52
52
  end
@@ -57,7 +57,7 @@ module Metanorma
57
57
  <<~TEMPLATE
58
58
  '******* CLASS GROUPS *************************************************
59
59
  #{join_as_plantuml(
60
- groups_to_plantuml(yml['groups'])
60
+ groups_to_plantuml(yml['groups']),
61
61
  )}
62
62
  TEMPLATE
63
63
  end
@@ -69,7 +69,7 @@ module Metanorma
69
69
  '******* CLASS RELATIONS **********************************************
70
70
  #{join_as_plantuml(
71
71
  classes_to_relations_plantuml(yml['classes']),
72
- relations_to_plantuml(nil, yml['relations'])
72
+ relations_to_plantuml(nil, yml['relations']),
73
73
  )}
74
74
  TEMPLATE
75
75
  end
@@ -80,7 +80,7 @@ module Metanorma
80
80
  <<~TEMPLATE
81
81
  '******* DIAGRAM SPECIFIC CONFIG **************************************
82
82
  #{join_as_plantuml(
83
- diagram_options_to_plantuml(yml['diagram_options'])
83
+ diagram_options_to_plantuml(yml['diagram_options']),
84
84
  )}
85
85
  TEMPLATE
86
86
  end
@@ -122,7 +122,7 @@ module Metanorma
122
122
  class #{class_name}#{model_stereotype_to_plantuml(class_hash['type'])} {
123
123
  #{join_as_plantuml(
124
124
  attributes_to_plantuml(class_hash['attributes']),
125
- constraints_to_plantuml(class_hash['constraints'])
125
+ constraints_to_plantuml(class_hash['constraints']),
126
126
  )}
127
127
  }
128
128
  TEMPLATE
@@ -165,7 +165,7 @@ module Metanorma
165
165
  <<~TEMPLATE
166
166
  __ constraints __
167
167
  #{join_as_plantuml(
168
- *constraints_output
168
+ *constraints_output,
169
169
  )}
170
170
  TEMPLATE
171
171
  end
@@ -218,14 +218,14 @@ module Metanorma
218
218
 
219
219
  def source_arrow_end(source, relationship)
220
220
  source_attribute = relationship_cardinality_to_plantuml(
221
- relationship["source"]["attribute"]
221
+ relationship["source"]["attribute"],
222
222
  )
223
223
  [source, source_attribute].join(" ")
224
224
  end
225
225
 
226
226
  def target_arrow_end(target, relationship, action)
227
227
  target_attribute = relationship_cardinality_to_plantuml(
228
- relationship["target"]["attribute"]
228
+ relationship["target"]["attribute"],
229
229
  )
230
230
  [
231
231
  [target_attribute, target].join(" "),
@@ -283,7 +283,7 @@ module Metanorma
283
283
  if attribute_cardinality
284
284
  cardinality = attribute_cardinality_plantuml(
285
285
  attribute_cardinality,
286
- false
286
+ false,
287
287
  )
288
288
  cardinality = " #{cardinality}"
289
289
  end
@@ -24,7 +24,7 @@ module Metanorma
24
24
  def init_indent(line)
25
25
  /^(?<prefix>[ \t]*)(?<suffix>.*)$/ =~ line
26
26
  prefix = prefix.gsub("\t", "\u00a0\u00a0\u00a0\u00a0")
27
- .gsub(/ /, "\u00a0")
27
+ .tr(" ", "\u00a0")
28
28
  prefix + suffix
29
29
  end
30
30
 
@@ -126,19 +126,49 @@ module Metanorma
126
126
 
127
127
  def inlinelink_escape(text)
128
128
  text.gsub(InlineLinkRx) do
129
- body, suffix = $4.nil? ? [$3 + $6, "[]"] : [$3, ""]
130
- p = $1 and s = $2 and b = $4
131
- if p == "link:" then "#{p}++#{s}#{body}++#{b}#{suffix}"
132
- elsif p == "<"
133
- "#{p}link:++#{s}#{body.sub(/>$/, '')}++#{b}#{suffix}>"
134
- else "#{p}link:++#{s}#{body}++#{b}#{suffix}"
129
+ p = $1 and s = $2 and body = $3
130
+ suffix = $4.nil? ? "[]" : ""
131
+ wrapper = $6
132
+ if (!/^(&lt;|[<\(\["'])$/.match?($1) || $6 != BRACKETS[$1]) && $4.nil?
133
+ body += $6
134
+ wrapper = ""
135
135
  end
136
+ # body, suffix = $4.nil? ? [$3 + $6, "[]"] : [$3, ""]
137
+ b = linkcontents_escape($4)
138
+ if p == "link:"
139
+ "#{p}++#{s}#{body}++#{b}#{suffix}"
140
+ else
141
+ "#{p}link:++#{s}#{body}++#{b}#{suffix}#{wrapper}"
142
+ end
143
+ end
144
+ end
145
+
146
+ BRACKETS = {
147
+ "<" => ">",
148
+ "&lt;" => "&gt;",
149
+ "[" => "]",
150
+ '"' => '"',
151
+ "'" => "'",
152
+ }.freeze
153
+
154
+ # because links are escaped, https within link text also need
155
+ # to be escaped, # otherwise they will be treated as links themselves
156
+ def linkcontents_escape(text)
157
+ text.nil? and return nil
158
+ text
159
+ # .gsub(InlineLinkMacroRx) do
160
+ # $1.empty? ? "\\#{$2}#{$3}#{$4}" : text
161
+ # end
162
+ .gsub(InlineLinkRx) do
163
+ esc = $1 == "link:" ? "" : "\\"
164
+ x = $4 || "#{$5}#{$6}"
165
+ "#{$1}#{esc}#{$2}#{$3}#{x}"
136
166
  end
137
167
  end
138
168
 
139
169
  # InlineLinkMacroRx = /\\?(?:link|(mailto)):(|[^:\s\[][^\s\[]*)\[(|#{CC_ALL}*?[^\\])\]/m
140
170
  InlineLinkMacroRx1 = <<~REGEX.freeze
141
- (\\\\?\\b(?<!-) # optional backslash, no hyphen, word boundary
171
+ (\\\\?)(\\b(?<!-) # optional backslash, no hyphen, word boundary
142
172
  (?:link|mailto):) # link: or mailto:
143
173
  (?!\\+) # no link:+ passthrough
144
174
  (|[^:\\s\\[][^\\s\\[]*) # link: ... up to [
@@ -151,7 +181,7 @@ module Metanorma
151
181
  ((text.include? "link:") || (text.include? "ilto:"))) or return text
152
182
  pass_inline_split(text) do |x|
153
183
  x.gsub(InlineLinkMacroRx) do
154
- "#{$1}++#{$2}++#{$3}"
184
+ "#{$1}#{$2}++#{$3}++#{linkcontents_escape($4)}"
155
185
  end
156
186
  end.join
157
187
  end
@@ -34,7 +34,7 @@ module Metanorma
34
34
 
35
35
  def requirement_validate(docxml)
36
36
  docxml.xpath("//requirement | //recommendation | //permission")
37
- .each_with_object([]) do |r, m|
37
+ .each do |r|
38
38
  @reqt_models.model(r["model"]).validate(r, @log)
39
39
  end
40
40
  end
@@ -38,7 +38,7 @@ module Metanorma
38
38
  case span[:key]
39
39
  when "uri", "docid"
40
40
  val = link_unwrap(Nokogiri::XML.fragment(span[:val])).to_xml
41
- ret[span[:key].to_sym] << { type: span[:type], val: val }
41
+ ret[span[:key].to_sym] << { type: span[:type], val: }
42
42
  when "date"
43
43
  ret[span[:key].to_sym] << { type: span[:type] || "published",
44
44
  val: span[:val] }
@@ -79,7 +79,7 @@ module Metanorma
79
79
  else
80
80
  msg = "unrecognised key '#{span[:key]}' in " \
81
81
  "`span:#{span[:key]}[#{span[:val]}]`"
82
- @err << { msg: msg }
82
+ @err << { msg: }
83
83
  end
84
84
  end
85
85
 
@@ -62,22 +62,24 @@ module Metanorma
62
62
  end
63
63
 
64
64
  def preferred_validate(doc)
65
- out = []
66
65
  ret = doc.xpath("//term").each_with_object({}) do |t, m|
67
66
  prefix = t.at("./domain")&.text
68
67
  t.xpath("./preferred//name").each do |n|
69
68
  ret = n.text
70
69
  prefix and ret = "<#{prefix}> #{ret}"
71
- (m[ret] and out << ret) or m[ret] = t
70
+ m[ret] ||= []
71
+ m[ret] << t
72
72
  end
73
73
  end
74
- preferred_validate_report(out, ret)
74
+ preferred_validate_report(ret)
75
75
  end
76
76
 
77
- def preferred_validate_report(terms, locations)
78
- terms.each do |e|
79
- err = "Term #{e} occurs twice as preferred designation"
80
- @log.add("Terms", locations[e], err, severity: 1)
77
+ def preferred_validate_report(terms)
78
+ terms.each do |k, v|
79
+ v.size > 1 or next
80
+ loc = v.map { |x| x["id"] }.join(", ")
81
+ err = "Term #{k} occurs twice as preferred designation: #{loc}"
82
+ @log.add("Terms", v.first, err, severity: 1)
81
83
  end
82
84
  end
83
85
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.9.3".freeze
22
+ VERSION = "2.9.4".freeze
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.3
4
+ version: 2.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-06 00:00:00.000000000 Z
11
+ date: 2024-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable