metanorma-standoc 2.8.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ed917e2185484c68d9c76b23b7bf977ee03da83204d3ceae22fd4fc893b8dae0
4
- data.tar.gz: c1c7af6fd9cb9a958093cb698beb2523d16bee5cdc4b4a06140092690753f44b
3
+ metadata.gz: 6a5e5f1a3e1674d8e9cc0b3cdc0979195595b187e972e498616b30955cbc4512
4
+ data.tar.gz: 81b45e23e6ece67cd6a6d8d6bd747c439264faca7ee26daf58b6cbdc42dcd93d
5
5
  SHA512:
6
- metadata.gz: 491207a21d304b30840b19398d547a1eb5e55037bd93c3c39397a9d31a725cde2de5e88348e984958639415f8ea38dcd6091fb5888825775934609e83c79cf53
7
- data.tar.gz: aa771efa57e60c94ac9e8e65dc0fd00a6c9280a812ea1ecbc212cecb25547be7b492111a6fdcbfa0118ad855ca775772fbedfc1d83c92fd3d3fff68b89a8f950
6
+ metadata.gz: 33d2ba8ae3a9b5ed18bf30193c507bcc6da280054dcc5c6c22e0f87288e6d229fb2bbcc62175826918d2b25935f1b6fc84f7d68f64e925a438c1d20fe6845f77
7
+ data.tar.gz: acab296d523a22e518a64ef1d1109706bfe4e3b164366f237b09a42e804ac371bf3387cd40122ea1f9eb0e42f9fa86796140826fd0013b44417b9d792cc3751a
@@ -48,14 +48,14 @@ module Metanorma
48
48
  { target: target, hidden: match[:hidden],
49
49
  type: match[:fn].nil? ? "inline" : "footnote",
50
50
  case: match[:case]&.sub(/%$/, ""),
51
- style: match[:style]&.sub(/^style=/, "")&.sub(/%$/, "") || @xrefstyle,
51
+ style: match[:style] || @xrefstyle,
52
52
  droploc: match[:drop].nil? && match[:drop2].nil? ? nil : true,
53
53
  text: inline_anchor_xref_text(match, text) }
54
54
  end
55
55
 
56
56
  def inline_anchor_xref_match(text)
57
57
  /^(?:hidden%(?<hidden>[^,]+),?)?
58
- (?<style>style=[^%]+%)?
58
+ (?:style=(?<style>[^%]+)%)?
59
59
  (?<drop>droploc%)?(?<case>capital%|lowercase%)?(?<drop2>droploc%)?
60
60
  (?<fn>fn:?\s*)?(?<text>.*)$/x.match text
61
61
  end
@@ -68,11 +68,7 @@ module Metanorma
68
68
  end
69
69
 
70
70
  def inline_anchor_link(node)
71
- contents = node.text
72
- contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
73
- attributes = { target: node.target, alt: node.attr("title"),
74
- "update-type": node.attr("updatetype") ||
75
- node.attr("update-type") }
71
+ contents, attributes = inline_anchor_link_attrs(node)
76
72
  noko do |xml|
77
73
  xml.link **attr_code(attributes) do |l|
78
74
  l << contents
@@ -80,10 +76,18 @@ module Metanorma
80
76
  end.join
81
77
  end
82
78
 
79
+ def inline_anchor_link_attrs(node)
80
+ contents = node.text
81
+ contents = "" if node.target.gsub(%r{^mailto:}, "") == node.text
82
+ attributes = { target: node.target, alt: node.attr("title"),
83
+ style: node.attr("style")&.sub(/%$/, ""),
84
+ "update-type": node.attr("updatetype") ||
85
+ node.attr("update-type") }
86
+ [contents, attributes]
87
+ end
88
+
83
89
  def inline_anchor_bibref(node)
84
- eref_contents =
85
- @c.decode(node.text || node.target || node.id)
86
- &.sub(/^\[?([^\[\]]+?)\]?$/, "[\\1]")
90
+ eref_contents = inline_anchor_bibref_contents(node)
87
91
  @refids << (node.target || node.id)
88
92
  noko do |xml|
89
93
  xml.ref **attr_code(id: node.target || node.id) do |r|
@@ -92,6 +96,11 @@ module Metanorma
92
96
  end.join
93
97
  end
94
98
 
99
+ def inline_anchor_bibref_contents(node)
100
+ @c.decode(node.text || node.target || node.id)
101
+ &.sub(/^\[?([^\[\]]+?)\]?$/, "[\\1]")
102
+ end
103
+
95
104
  def inline_callout(node)
96
105
  noko do |xml|
97
106
  xml.callout node.text
@@ -244,6 +244,9 @@
244
244
  <data type="ID"/>
245
245
  </attribute>
246
246
  <attribute name="reviewer"/>
247
+ <optional>
248
+ <attribute name="type"/>
249
+ </optional>
247
250
  <optional>
248
251
  <attribute name="date">
249
252
  <data type="dateTime"/>
@@ -22,13 +22,12 @@ module Metanorma
22
22
  attr_code(
23
23
  from: node.attr("from"),
24
24
  to: node.attr("to") || node.attr("from"),
25
+ type: node.attr("type") || nil,
25
26
  ),
26
27
  )
27
28
  end
28
29
 
29
30
  def sidebar(node)
30
- return unless draft?
31
-
32
31
  noko do |xml|
33
32
  xml.review **sidebar_attrs(node) do |r|
34
33
  wrap_in_para(node, r)
@@ -42,7 +41,7 @@ module Metanorma
42
41
  attr_code(id_attr(node)
43
42
  .merge(reviewer: node.attr("reviewer") || node.attr("source") ||
44
43
  "(Unknown)",
45
- date: date))
44
+ date: date, type: "todo"))
46
45
  end
47
46
 
48
47
  def todo(node)
@@ -96,10 +95,7 @@ module Metanorma
96
95
  end
97
96
 
98
97
  def admonition(node)
99
- return termnote(node) if in_terms? && node.attr("name") == "note"
100
- return note(node) if node.attr("name") == "note"
101
- return todo(node) if node.attr("name") == "todo"
102
-
98
+ ret = admonition_alternatives(node) and return ret
103
99
  noko do |xml|
104
100
  xml.admonition **admonition_attrs(node) do |a|
105
101
  node.title.nil? or a.name { |name| name << node.title }
@@ -107,6 +103,13 @@ module Metanorma
107
103
  end
108
104
  end.join("\n")
109
105
  end
106
+
107
+ def admonition_alternatives(node)
108
+ in_terms? && node.attr("name") == "note" and return termnote(node)
109
+ node.attr("name") == "note" and return note(node)
110
+ node.attr("name") == "todo" and return todo(node)
111
+ nil
112
+ end
110
113
  end
111
114
  end
112
115
  end
@@ -29,6 +29,7 @@ module Metanorma
29
29
  element_name_cleanup(xmldoc)
30
30
  passthrough_cleanup(xmldoc)
31
31
  unnumbered_blocks_cleanup(xmldoc)
32
+ termdocsource_cleanup(xmldoc) # feeds: metadata_cleanup
32
33
  metadata_cleanup(xmldoc) # feeds: boilerplate_cleanup
33
34
  sections_cleanup(xmldoc) # feeds: obligations_cleanup, toc_cleanup,
34
35
  # floatingtitle_cleanup
@@ -14,11 +14,12 @@ module Metanorma
14
14
  end
15
15
 
16
16
  def strip_initial_space(elem)
17
- elem.children[0].text? or return
18
- if /\S/.match?(elem.children[0].text)
19
- elem.children[0].content = elem.children[0].text.lstrip
17
+ a = elem.children[0]
18
+ a.text? or return
19
+ if /\S/.match?(a.text)
20
+ a.content = a.text.lstrip
20
21
  else
21
- elem.children[0].remove
22
+ a.remove
22
23
  end
23
24
  end
24
25
 
@@ -208,6 +209,10 @@ module Metanorma
208
209
  end
209
210
 
210
211
  def link_cleanup(xmldoc)
212
+ uri_cleanup(xmldoc)
213
+ end
214
+
215
+ def uri_cleanup(xmldoc)
211
216
  xmldoc.xpath("//link[@target]").each do |l|
212
217
  l["target"] = Addressable::URI.parse(l["target"]).to_s
213
218
  rescue Addressable::URI::InvalidURIError
@@ -119,7 +119,6 @@ module Metanorma
119
119
  termdomain1_cleanup(xmldoc)
120
120
  termnote_example_cleanup(xmldoc)
121
121
  term_children_cleanup(xmldoc)
122
- termdocsource_cleanup(xmldoc)
123
122
  end
124
123
 
125
124
  def term_index_cleanup(xmldoc)
@@ -17,7 +17,7 @@
17
17
  these elements; we just want one namespace for any child grammars
18
18
  of this.
19
19
  -->
20
- <!-- VERSION v1.2.12 -->
20
+ <!-- VERSION v1.3.0 -->
21
21
  <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
22
22
  <include href="reqt.rng"/>
23
23
  <include href="basicdoc.rng">
@@ -146,6 +146,9 @@
146
146
  <data type="boolean"/>
147
147
  </attribute>
148
148
  </optional>
149
+ <optional>
150
+ <attribute name="style"/>
151
+ </optional>
149
152
  <oneOrMore>
150
153
  <ref name="PureTextElement"/>
151
154
  </oneOrMore>
@@ -24,10 +24,9 @@ module Metanorma
24
24
  def sectiontype(node, level = true)
25
25
  ret = sectiontype1(node)
26
26
  ret1 = preface_main_filter(sectiontype_streamline(ret), node)
27
- return ret1 if ret1 == "symbols and abbreviated terms"
28
- return nil unless !level || node.level == 1
29
- return nil if @seen_headers.include? ret
30
-
27
+ ret1 == "symbols and abbreviated terms" and return ret1
28
+ !level || node.level == 1 or return nil
29
+ @seen_headers.include? ret and return nil
31
30
  @seen_headers << ret unless ret1.nil?
32
31
  @seen_headers_canonical << ret1 unless ret1.nil?
33
32
  ret1
@@ -95,8 +94,8 @@ module Metanorma
95
94
  "multilingual-rendering": node&.attr("multilingual-rendering"),
96
95
  colophon: (if node.role == "colophon" ||
97
96
  node.attr("style") == "colophon"
98
- true
99
- end),
97
+ true
98
+ end),
100
99
  preface: (if node.role == "preface" ||
101
100
  node.attr("style") == "preface"
102
101
  true
@@ -152,13 +151,13 @@ module Metanorma
152
151
  end
153
152
 
154
153
  def set_obligation(attrs, node)
155
- attrs[:obligation] = if node.attributes.has_key?("obligation")
156
- node.attr("obligation")
157
- elsif node.parent.attributes.has_key?("obligation")
158
- node.parent.attr("obligation")
159
- else
160
- "normative"
161
- end
154
+ attrs[:obligation] =
155
+ if node.attributes.has_key?("obligation")
156
+ node.attr("obligation")
157
+ elsif node.parent.attributes.has_key?("obligation")
158
+ node.parent.attr("obligation")
159
+ else "normative"
160
+ end
162
161
  end
163
162
 
164
163
  def preamble(node)
@@ -167,8 +166,7 @@ module Metanorma
167
166
  xml_abstract.title do |t|
168
167
  t << (node.blocks[0].title || @i18n.foreword)
169
168
  end
170
- content = node.content
171
- xml_abstract << content
169
+ xml_abstract << node.content
172
170
  end
173
171
  end.join("\n")
174
172
  end
@@ -241,9 +239,9 @@ module Metanorma
241
239
  end
242
240
 
243
241
  def floating_title_attrs(node)
244
- attr_code(id_attr(node).merge(align: node.attr("align"),
245
- depth: node.level,
246
- type: "floating-title"))
242
+ attr_code(id_attr(node)
243
+ .merge(align: node.attr("align"), depth: node.level,
244
+ type: "floating-title"))
247
245
  end
248
246
 
249
247
  def floating_title(node)
@@ -64,9 +64,10 @@ module Metanorma
64
64
  lookup = norm_ref_id_text(refterm.text.strip)
65
65
  p = @lookup[:sec2prim][lookup] and refterm.children = @c.encode(p)
66
66
  p || @lookup[:term][lookup] and
67
- refterm.replace("<preferred><expression>" \
68
- "<name>#{refterm.children.to_xml}" \
69
- "</name></expression></preferred>")
67
+ refterm.replace(<<~XML,
68
+ <preferred><expression><name>#{refterm.children.to_xml}</name></expression></preferred>
69
+ XML
70
+ )
70
71
  end
71
72
  end
72
73
 
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.8.0".freeze
22
+ VERSION = "2.8.1".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.8.0
4
+ version: 2.8.1
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-01-09 00:00:00.000000000 Z
11
+ date: 2024-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable