metanorma-standoc 2.3.8 → 2.3.9

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: 00ae5b84e04807e4d13ce97c2be80f47fc46a0004c8a1630d59f041597627f9e
4
- data.tar.gz: 1e67f2c42a5b84081e44a6ad63b0cce70d980cc8478014de53355cf4b74e5e24
3
+ metadata.gz: 0fb752d30fc48409836f4b8b63f7f57864ffe6626f624ca2520875b918ff5df3
4
+ data.tar.gz: 5da9f771b4caa899c275a131c4484f0c0ae14a05041012994edd57de3588ff63
5
5
  SHA512:
6
- metadata.gz: 65608377bcc5b0b06e6895f6d9ed842c956def5cf77e28e25d4db3ae554b062f0e798afa2a964a18265396c22243d6aeebea98e913b4c269ddf09c04e3f06f92
7
- data.tar.gz: 01aff668829eb7d52cec2e94e9b9da8b06353b56847a615b543e6fa2cfefad4fe8e9a9cc0f72e266b74e4f7535671f23ed34b31da43b6cddffe14ba189165e4c
6
+ metadata.gz: 5c85f82ea6c5121977b3f511d5e70b74420bc8ed9f3256117ecf16a2547e454a9b738188d5ace110127533395b4d230787fbfef1dcb37384bc07f1a8403ffc0a
7
+ data.tar.gz: 8bcb04197dd817d9a853692935e07c76c70f2293821e4b1e2fb560a6e52c2eccc5b9dfc993ef5b562d09af75381e067af9dac5f2063d92c5995b447d0219c0a5
@@ -82,14 +82,20 @@ module Metanorma
82
82
  end
83
83
 
84
84
  def init_toc(node)
85
- @htmltoclevels = node.attr("htmltoclevels")
86
- @doctoclevels = node.attr("doctoclevels")
87
- @toclevels = node.attr("toclevels")
85
+ @htmltoclevels = node.attr("htmltoclevels") ||
86
+ node.attr("toclevels") || toc_default[:html_levels]
87
+ @doctoclevels = node.attr("doctoclevels") ||
88
+ node.attr("toclevels") || toc_default[:word_levels]
89
+ @toclevels = node.attr("toclevels") || toc_default[:word_levels]
88
90
  @tocfigures = node.attr("toc-figures")
89
91
  @toctables = node.attr("toc-tables")
90
92
  @tocrecommendations = node.attr("toc-recommendations")
91
93
  end
92
94
 
95
+ def toc_default
96
+ { word_levels: 2, html_levels: 2 }
97
+ end
98
+
93
99
  def init_output(node)
94
100
  @fontheader = default_fonts(node)
95
101
  @log = Metanorma::Utils::Log.new
@@ -216,6 +216,9 @@
216
216
  <optional>
217
217
  <ref name="fullname"/>
218
218
  </optional>
219
+ <zeroOrMore>
220
+ <ref name="credential"/>
221
+ </zeroOrMore>
219
222
  <zeroOrMore>
220
223
  <ref name="affiliation"/>
221
224
  </zeroOrMore>
@@ -232,6 +235,11 @@
232
235
  <ref name="FullNameType"/>
233
236
  </element>
234
237
  </define>
238
+ <define name="credential">
239
+ <element name="credential">
240
+ <text/>
241
+ </element>
242
+ </define>
235
243
  <define name="FullNameType">
236
244
  <choice>
237
245
  <group>
@@ -305,7 +313,9 @@
305
313
  <zeroOrMore>
306
314
  <ref name="affiliationdescription"/>
307
315
  </zeroOrMore>
308
- <ref name="organization"/>
316
+ <optional>
317
+ <ref name="organization"/>
318
+ </optional>
309
319
  </element>
310
320
  </define>
311
321
  <define name="affiliationname">
@@ -60,6 +60,7 @@ module Metanorma
60
60
  quotesource_cleanup(xmldoc)
61
61
  callout_cleanup(xmldoc)
62
62
  footnote_cleanup(xmldoc)
63
+ ol_cleanup(xmldoc)
63
64
  mathml_cleanup(xmldoc)
64
65
  script_cleanup(xmldoc)
65
66
  docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
@@ -100,8 +100,7 @@ module Metanorma
100
100
  # it is moved inside its preceding block if it is not delimited
101
101
  # (so there was no way of making that block include the note)
102
102
  def note_cleanup(xmldoc)
103
- q = "//note[following-sibling::*[not(local-name() = 'note')]]"
104
- xmldoc.xpath(q).each do |n|
103
+ xmldoc.xpath("//note").each do |n|
105
104
  next if n["keep-separate"] == "true" || !n.ancestors("table").empty?
106
105
 
107
106
  prev = n.previous_element || next
@@ -221,6 +220,14 @@ module Metanorma
221
220
  foll.children.first.previous = para.remove.children
222
221
  end
223
222
  end
223
+
224
+ def ol_cleanup(doc)
225
+ doc.xpath("//ol[@explicit-type]").each do |x|
226
+ x.delete("explicit-type")
227
+ @log.add("Bibliography", x,
228
+ "Style override set for ordered list")
229
+ end
230
+ end
224
231
  end
225
232
  end
226
233
  end
@@ -80,7 +80,7 @@ module Metanorma
80
80
  types = MIME::Types.type_for(path) or return false
81
81
  types.first == "image/svg+xml" or return false
82
82
  svg = File.read(path, encoding: "utf-8") or return false
83
- img.replace(Nokogiri::XML(svg).root.to_xml)
83
+ img.replace(Nokogiri::XML(svg).root)
84
84
  true
85
85
  end
86
86
 
@@ -11,18 +11,31 @@ module Metanorma
11
11
  if xml.at("//foreword | //introduction | //acknowledgements | " \
12
12
  "//*[@preface]")
13
13
  preface = sect.add_previous_sibling("<preface/>").first
14
- f = xml.at("//foreword") and preface.add_child f.remove
15
- f = xml.at("//introduction") and preface.add_child f.remove
14
+ f = xml.at("//foreword") and to_preface(preface, f)
15
+ f = xml.at("//introduction") and to_preface(preface, f)
16
16
  move_clauses_into_preface(xml, preface)
17
- f = xml.at("//acknowledgements") and preface.add_child f.remove
17
+ f = xml.at("//acknowledgements") and to_preface(preface, f)
18
18
  end
19
19
  make_abstract(xml, sect)
20
20
  end
21
21
 
22
22
  def move_clauses_into_preface(xml, preface)
23
23
  xml.xpath("//*[@preface]").each do |c|
24
- c.delete("preface")
25
- preface.add_child c.remove
24
+ to_preface(preface, c)
25
+ end
26
+ end
27
+
28
+ def to_preface(preface, clause)
29
+ clause.delete("preface")
30
+ preface.add_child clause.remove
31
+ end
32
+
33
+ def make_colophon(xml)
34
+ xml.at("//clause[@colophon]") or return
35
+ colophon = xml.root.add_child("<colophon/>").first
36
+ xml.xpath("//*[@colophon]").each do |c|
37
+ c.delete("colophon")
38
+ colophon.add_child c.remove
26
39
  end
27
40
  end
28
41
 
@@ -77,6 +90,7 @@ module Metanorma
77
90
  make_annexes(xml)
78
91
  make_indexsect(xml, s)
79
92
  make_bibliography(xml, s)
93
+ make_colophon(xml)
80
94
  xml.xpath("//sections/annex").reverse_each { |r| s.next = r.remove }
81
95
  end
82
96
 
@@ -86,9 +86,9 @@ module Metanorma
86
86
 
87
87
  def toc_metadata1(ins)
88
88
  [[@toclevels, "TOC Heading Levels"],
89
- [@toclevels, "TOC Heading Levels"],
90
- [@toclevels, "TOC Heading Levels"]].each do |n|
91
- n[0] and ins << "<presentation-metadata><name>#{n[1]}</name>"\
89
+ [@htmltoclevels, "HTML TOC Heading Levels"],
90
+ [@doctoclevels, "DOC TOC Heading Levels"]].each do |n|
91
+ n[0] and ins << "<presentation-metadata><name>#{n[1]}</name>" \
92
92
  "<value>#{n[0]}</value></presentation-metadata>"
93
93
  end
94
94
  end
@@ -9,12 +9,17 @@ module Metanorma
9
9
  module Standoc
10
10
  module Front
11
11
  def metadata_id(node, xml)
12
+ id = node.attr("docidentifier") || metadata_id_build(node)
13
+ xml.docidentifier id
14
+ xml.docnumber node.attr("docnumber")
15
+ end
16
+
17
+ def metadata_id_build(node)
12
18
  part, subpart = node&.attr("partnumber")&.split(/-/)
13
19
  id = node.attr("docnumber") || ""
14
20
  id += "-#{part}" if part
15
21
  id += "-#{subpart}" if subpart
16
- xml.docidentifier id
17
- xml.docnumber node.attr("docnumber")
22
+ id
18
23
  end
19
24
 
20
25
  def metadata_other_id(node, xml)
@@ -69,7 +74,7 @@ module Metanorma
69
74
 
70
75
  def metadata_date1(node, xml, type)
71
76
  date = node.attr("#{type}-date")
72
- date and xml.date **{ type: type } do |d|
77
+ date and xml.date type: type do |d|
73
78
  d.on date
74
79
  end
75
80
  end
@@ -87,7 +92,7 @@ module Metanorma
87
92
 
88
93
  type, date = node.attr(a).split(/ /, 2)
89
94
  type or next
90
- xml.date **{ type: type } do |d|
95
+ xml.date type: type do |d|
91
96
  d.on date
92
97
  end
93
98
  end
@@ -134,7 +139,7 @@ module Metanorma
134
139
 
135
140
  def metadata_getrelation1(doc, xml, type, desc)
136
141
  id = doc.split(/,\s*/)
137
- xml.relation **{ type: relation_normalise(type) } do |r|
142
+ xml.relation type: relation_normalise(type) do |r|
138
143
  desc.nil? or r.description desc.gsub(/-/, " ")
139
144
  fetch_ref(r, doc, nil, **{}) or r.bibitem do |b|
140
145
  b.title id[1] || "--"
@@ -86,6 +86,7 @@ module Metanorma
86
86
  personal_role(node, c, suffix)
87
87
  c.person do |p|
88
88
  person_name(node, xml, suffix, p)
89
+ person_credentials(node, xml, suffix, p)
89
90
  person_affiliation(node, xml, suffix, p)
90
91
  personal_contact(node, suffix, p)
91
92
  end
@@ -104,9 +105,17 @@ module Metanorma
104
105
  end
105
106
  end
106
107
 
108
+ def person_credentials(node, _xml, suffix, person)
109
+ c = node.attr("contributor-credentials#{suffix}") and
110
+ person.credentials c
111
+ end
112
+
107
113
  def person_affiliation(node, _xml, suffix, person)
108
- node.attr("affiliation#{suffix}") and person.affiliation do |a|
109
- a.organization do |o|
114
+ aff = node.attr("affiliation#{suffix}")
115
+ pos = node.attr("contributor-position#{suffix}")
116
+ (aff || pos) and person.affiliation do |a|
117
+ pos and a.name pos
118
+ aff and a.organization do |o|
110
119
  person_organization(node, suffix, o)
111
120
  end
112
121
  end
@@ -1578,6 +1578,9 @@
1578
1578
  <zeroOrMore>
1579
1579
  <ref name="indexsect"/>
1580
1580
  </zeroOrMore>
1581
+ <optional>
1582
+ <ref name="colophon"/>
1583
+ </optional>
1581
1584
  </element>
1582
1585
  </define>
1583
1586
  <define name="misccontainer">
@@ -1600,6 +1603,13 @@
1600
1603
  </oneOrMore>
1601
1604
  </element>
1602
1605
  </define>
1606
+ <define name="colophon">
1607
+ <element name="colophon">
1608
+ <oneOrMore>
1609
+ <ref name="content"/>
1610
+ </oneOrMore>
1611
+ </element>
1612
+ </define>
1603
1613
  <define name="foreword">
1604
1614
  <element name="foreword">
1605
1615
  <ref name="Content-Section"/>
@@ -53,9 +53,12 @@ module Metanorma
53
53
  style
54
54
  end
55
55
 
56
+ # node.attributes[1] == node.style only if style explicitly set
57
+ # as a positional attribute
56
58
  def ol_attrs(node)
57
59
  attr_code(id_attr(node).merge(keep_attrs(node)
58
- .merge(type: olist_style(node.style))))
60
+ .merge(type: olist_style(node.style),
61
+ "explicit-type": olist_style(node.attributes[1]))))
59
62
  end
60
63
 
61
64
  def olist(node)
@@ -35,7 +35,7 @@ module Metanorma
35
35
  end
36
36
 
37
37
  def merge1(old, new)
38
- %i(link docidentifier date title series).each do |k|
38
+ %i(link docid date title series).each do |k|
39
39
  merge_by_type(old, new, k, :type)
40
40
  end
41
41
  merge_extent(old, new)
@@ -92,6 +92,10 @@ module Metanorma
92
92
  end),
93
93
  tag: node&.attr("tag"),
94
94
  "multilingual-rendering": node&.attr("multilingual-rendering"),
95
+ colophon: (if node.role == "colophon" ||
96
+ node.attr("style") == "colophon"
97
+ true
98
+ end),
95
99
  preface: (if node.role == "preface" ||
96
100
  node.attr("style") == "preface"
97
101
  true
@@ -9,11 +9,18 @@ module Metanorma
9
9
  def initialize(bib)
10
10
  @bib = bib
11
11
  @err = []
12
- @spans = spans_preprocess(extract_content(bib))
12
+ @spans = spans_preprocess(extract_spans(bib))
13
+ ids = spans_preprocess(extract_docid(bib))
14
+ @spans[:docid] = override_docids(ids[:docid], @spans[:docid])
13
15
  end
14
16
 
15
- def extract_content(bib)
16
- extract_docid(bib) + extract_spans(bib)
17
+ def override_docids(old, new)
18
+ ret = new
19
+ keys = new.map { |a| a[:type] }
20
+ old.each do |e|
21
+ keys.include?(e[:type]) or ret << e
22
+ end
23
+ ret
17
24
  end
18
25
 
19
26
  def extract_spans(bib)
@@ -97,18 +97,6 @@ module Metanorma
97
97
  @fatalerror << err2
98
98
  end
99
99
 
100
- def norm_ref_validate(doc)
101
- found = false
102
- doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
103
- docid = b.at("./docidentifier[@type = 'metanorma']") or next
104
- /^\[\d+\]$/.match?(docid.text) or next
105
- @log.add("Bibliography", b,
106
- "Numeric reference in normative references")
107
- found = true
108
- end
109
- found and @fatalerror << "Numeric reference in normative references"
110
- end
111
-
112
100
  def concept_validate(doc, tag, refterm)
113
101
  found = false
114
102
  concept_validate_ids(doc)
@@ -40,7 +40,7 @@ module Metanorma
40
40
  end
41
41
 
42
42
  def hanging_para_style(root)
43
- root.xpath("//clause | //annex | //foreword | //introduction | "\
43
+ root.xpath("//clause | //annex | //foreword | //introduction | " \
44
44
  "//acknowledgements").each do |c|
45
45
  next unless c.at("./clause")
46
46
  next if c.elements.reject do |n|
@@ -50,6 +50,18 @@ module Metanorma
50
50
  style_warning(c, "Hanging paragraph in clause")
51
51
  end
52
52
  end
53
+
54
+ def norm_ref_validate(doc)
55
+ found = false
56
+ doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
57
+ docid = b.at("./docidentifier[@type = 'metanorma']") or next
58
+ /^\[\d+\]$/.match?(docid.text) or next
59
+ @log.add("Bibliography", b,
60
+ "Numeric reference in normative references")
61
+ found = true
62
+ end
63
+ found and @fatalerror << "Numeric reference in normative references"
64
+ end
53
65
  end
54
66
  end
55
67
  end
@@ -19,6 +19,6 @@ module Metanorma
19
19
  end
20
20
 
21
21
  module Standoc
22
- VERSION = "2.3.8".freeze
22
+ VERSION = "2.3.9".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.3.8
4
+ version: 2.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-07 00:00:00.000000000 Z
11
+ date: 2023-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor