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 +4 -4
- data/lib/metanorma/standoc/base.rb +9 -3
- data/lib/metanorma/standoc/biblio.rng +11 -1
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_block.rb +9 -2
- data/lib/metanorma/standoc/cleanup_image.rb +1 -1
- data/lib/metanorma/standoc/cleanup_section.rb +19 -5
- data/lib/metanorma/standoc/cleanup_toc.rb +3 -3
- data/lib/metanorma/standoc/front.rb +10 -5
- data/lib/metanorma/standoc/front_contributor.rb +11 -2
- data/lib/metanorma/standoc/isodoc.rng +10 -0
- data/lib/metanorma/standoc/lists.rb +4 -1
- data/lib/metanorma/standoc/merge_bibitems.rb +1 -1
- data/lib/metanorma/standoc/section.rb +4 -0
- data/lib/metanorma/standoc/spans_to_bibitem.rb +10 -3
- data/lib/metanorma/standoc/validate.rb +0 -12
- data/lib/metanorma/standoc/validate_section.rb +13 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0fb752d30fc48409836f4b8b63f7f57864ffe6626f624ca2520875b918ff5df3
|
4
|
+
data.tar.gz: 5da9f771b4caa899c275a131c4484f0c0ae14a05041012994edd57de3588ff63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
87
|
-
@
|
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
|
-
<
|
316
|
+
<optional>
|
317
|
+
<ref name="organization"/>
|
318
|
+
</optional>
|
309
319
|
</element>
|
310
320
|
</define>
|
311
321
|
<define name="affiliationname">
|
@@ -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
|
-
|
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
|
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
|
15
|
-
f = xml.at("//introduction") and preface
|
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
|
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
|
-
|
25
|
-
|
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
|
-
[@
|
90
|
-
[@
|
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
|
-
|
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
|
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
|
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
|
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}")
|
109
|
-
|
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)
|
@@ -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(
|
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
|
16
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|