metanorma-standoc 2.8.0 → 2.8.2
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/anchor.rb +19 -10
- data/lib/metanorma/standoc/basicdoc.rng +3 -0
- data/lib/metanorma/standoc/blocks_notes.rb +10 -7
- data/lib/metanorma/standoc/cleanup.rb +12 -3
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +37 -8
- data/lib/metanorma/standoc/cleanup_inline.rb +9 -4
- data/lib/metanorma/standoc/cleanup_terms.rb +0 -1
- data/lib/metanorma/standoc/cleanup_xref.rb +32 -10
- data/lib/metanorma/standoc/front.rb +10 -11
- data/lib/metanorma/standoc/isodoc.rng +4 -1
- data/lib/metanorma/standoc/macros_inline.rb +11 -4
- data/lib/metanorma/standoc/ref.rb +17 -9
- data/lib/metanorma/standoc/ref_sect.rb +3 -2
- data/lib/metanorma/standoc/section.rb +16 -18
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +4 -3
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -3
- metadata +6 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2015e269893b92d91e3b1f7fabe93f706693d7a45da1719daac5b60e04f0011
|
4
|
+
data.tar.gz: 2ac72c8476a05968b34648c05eec685f8339dfbe711780ed7b1b7f646c94aa2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1df98678c7d010abdbdc9c4ba754ca1892ce75c5d4aa7bb882642bca4e3b4df725c9b3ae01b208a0b0cfe77dbf23eec2d7742e5a402c574479170f1140ebc71b
|
7
|
+
data.tar.gz: 6340b42bc795cc70c3184a5d3b268c726dec16705f1396a6fc3d298c882eaf0b21d08f8bb0d982db30829518b24a6f09256361218d10b3ff8083ac00c1aadd68
|
@@ -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]
|
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>
|
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
|
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
|
@@ -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
|
-
|
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
|
@@ -52,15 +53,16 @@ module Metanorma
|
|
52
53
|
normref_cleanup(xmldoc)
|
53
54
|
biblio_cleanup(xmldoc)
|
54
55
|
reference_names(xmldoc)
|
55
|
-
asciimath_cleanup(xmldoc) # feeds: mathml_cleanup, termdef_cleanup,
|
56
|
+
asciimath_cleanup(xmldoc) # feeds: mathml_cleanup, termdef_cleanup,
|
57
|
+
# symbols_cleanup
|
56
58
|
symbols_cleanup(xmldoc) # feeds: termdef_cleanup
|
57
59
|
xref_cleanup(xmldoc) # feeds: concept_cleanup, origin_cleanup
|
58
60
|
concept_cleanup(xmldoc) # feeds: related_cleanup, termdef_cleanup
|
59
61
|
related_cleanup(xmldoc) # feeds: termdef_cleanup
|
60
62
|
origin_cleanup(xmldoc) # feeds: termdef_cleanup
|
61
63
|
bookmark_cleanup(xmldoc)
|
62
|
-
termdef_cleanup(xmldoc) # feeds:
|
63
|
-
|
64
|
+
termdef_cleanup(xmldoc) # feeds: relaton_iev_cleanup, term_index_cleanup
|
65
|
+
relaton_iev_cleanup(xmldoc)
|
64
66
|
element_name_cleanup(xmldoc)
|
65
67
|
term_index_cleanup(xmldoc)
|
66
68
|
bpart_cleanup(xmldoc)
|
@@ -87,6 +89,13 @@ module Metanorma
|
|
87
89
|
xmldoc
|
88
90
|
end
|
89
91
|
|
92
|
+
def relaton_iev_cleanup(xmldoc)
|
93
|
+
_, err = RelatonIev::iev_cleanup(xmldoc, @bibdb)
|
94
|
+
err.each do |e|
|
95
|
+
@log.add("Bibliography", nil, e, severity: 0)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
90
99
|
def docidentifier_cleanup(xmldoc); end
|
91
100
|
|
92
101
|
TEXT_ELEMS =
|
@@ -3,14 +3,16 @@ module Metanorma
|
|
3
3
|
module Cleanup
|
4
4
|
def external_terms_boilerplate(sources)
|
5
5
|
@i18n.l10n(
|
6
|
-
@i18n.external_terms_boilerplate.gsub(
|
6
|
+
@i18n.external_terms_boilerplate.gsub(/%(?=\p{P}|\p{Z}|$)/,
|
7
|
+
sources || "???"),
|
7
8
|
@lang, @script, @locale
|
8
9
|
)
|
9
10
|
end
|
10
11
|
|
11
12
|
def internal_external_terms_boilerplate(sources)
|
12
13
|
@i18n.l10n(
|
13
|
-
@i18n.internal_external_terms_boilerplate.gsub(
|
14
|
+
@i18n.internal_external_terms_boilerplate.gsub(/%(?=\p{P}|\p{Z}|$)/,
|
15
|
+
sources || "??"),
|
14
16
|
@lang, @script
|
15
17
|
)
|
16
18
|
end
|
@@ -139,13 +141,40 @@ module Metanorma
|
|
139
141
|
xml.at("//metanorma-extension/semantic-metadata/" \
|
140
142
|
"headless[text() = 'true']") and return nil
|
141
143
|
file = boilerplate_file(xml)
|
142
|
-
@boilerplateauthority and
|
143
|
-
|
144
|
-
(
|
145
|
-
|
144
|
+
@boilerplateauthority and
|
145
|
+
file2 = File.join(@localdir, @boilerplateauthority)
|
146
|
+
resolve_boilerplate_files(process_boilerplate_file(file, conv),
|
147
|
+
process_boilerplate_file(file2, conv))
|
148
|
+
end
|
149
|
+
|
150
|
+
def process_boilerplate_file(filename, conv)
|
151
|
+
(!filename.nil? and File.exist?(filename)) or return
|
152
|
+
b = conv.populate_template(boilerplate_read(filename), nil)
|
146
153
|
boilerplate_file_convert(b)
|
147
154
|
end
|
148
155
|
|
156
|
+
def resolve_boilerplate_files(built_in, user_add)
|
157
|
+
built_in || user_add or return
|
158
|
+
built_in && user_add or return to_xml(built_in || user_add)
|
159
|
+
merge_boilerplate_files(built_in, user_add)
|
160
|
+
end
|
161
|
+
|
162
|
+
def merge_boilerplate_files(built_in, user_add)
|
163
|
+
%w(copyright license legal feedback).each do |w|
|
164
|
+
resolve_boilerplate_statement(built_in, user_add, w)
|
165
|
+
end
|
166
|
+
to_xml(built_in)
|
167
|
+
end
|
168
|
+
|
169
|
+
def resolve_boilerplate_statement(built_in, user_add, statement)
|
170
|
+
b = user_add.at("./#{statement}-statement") or return
|
171
|
+
if a = built_in.at("./#{statement}-statement")
|
172
|
+
b.text.strip.empty? and a.remove or a.replace(b)
|
173
|
+
else
|
174
|
+
built_in << b
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
149
178
|
def boilerplate_read(file)
|
150
179
|
ret = File.read(file, encoding: "UTF-8")
|
151
180
|
/\.adoc$/.match?(file) and
|
@@ -155,8 +184,8 @@ module Metanorma
|
|
155
184
|
|
156
185
|
# If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
|
157
186
|
def boilerplate_file_convert(file)
|
158
|
-
Nokogiri::XML(file).root and return
|
159
|
-
|
187
|
+
ret = Nokogiri::XML(file).root and return ret
|
188
|
+
boilerplate_file_restructure(file)
|
160
189
|
end
|
161
190
|
|
162
191
|
# If Asciidoctor, convert top clauses to tags and wrap in <boilerplate>
|
@@ -14,11 +14,12 @@ module Metanorma
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def strip_initial_space(elem)
|
17
|
-
elem.children[0]
|
18
|
-
|
19
|
-
|
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
|
-
|
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
|
@@ -4,18 +4,22 @@ module Metanorma
|
|
4
4
|
# extending localities to cover ISO referencing
|
5
5
|
CONN_REGEX_STR = "(?<conn>and|or|from|to)!".freeze
|
6
6
|
|
7
|
+
LOCALITIES = "section|clause|part|paragraph|chapter|page|line|" \
|
8
|
+
"table|annex|figure|example|note|formula|list|time|anchor|" \
|
9
|
+
"locality:[^ \\t\\n\\r:,;=]+".freeze
|
10
|
+
|
7
11
|
LOCALITY_REGEX_STR = <<~REGEXP.freeze
|
8
12
|
^((#{CONN_REGEX_STR})?
|
9
|
-
(?<locality
|
10
|
-
table|annex|figure|example|note|formula|list|time|anchor|
|
11
|
-
locality:[^ \\t\\n\\r:,;=]+)(\\s+|=)
|
13
|
+
(?<locality>#{LOCALITIES})(\\s+|=)
|
12
14
|
(?<ref>[^"][^ \\t\\n,:;-]*|"[^"]+")
|
13
15
|
(-(?<to>[^"][^ \\t\\n,:;-]*|"[^"]"))?|
|
14
16
|
(?<locality2>whole|title|locality:[^ \\t\\n\\r:,;=]+))(?<punct>[,:;]?)\\s*
|
15
17
|
(?<text>.*)$
|
16
18
|
REGEXP
|
17
|
-
|
18
|
-
|
19
|
+
|
20
|
+
def to_regex(str)
|
21
|
+
Regexp.new(str.gsub(/\s/, ""), Regexp::IGNORECASE | Regexp::MULTILINE)
|
22
|
+
end
|
19
23
|
|
20
24
|
LOCALITY_REGEX_VALUE_ONLY_STR = <<~REGEXP.freeze
|
21
25
|
^(?<conn0>(#{CONN_REGEX_STR}))
|
@@ -23,8 +27,6 @@ module Metanorma
|
|
23
27
|
(?<value>[^=,;:\\t\\n\\r]+)
|
24
28
|
(?<punct>[,;\\t\\n\\r]|$)
|
25
29
|
REGEXP
|
26
|
-
LOCALITY_VAL_ONLY_RE = Regexp.new(LOCALITY_REGEX_VALUE_ONLY_STR
|
27
|
-
.gsub(/\s/, ""), Regexp::IGNORECASE | Regexp::MULTILINE)
|
28
30
|
|
29
31
|
def tq(text)
|
30
32
|
text.sub(/^"/, "").sub(/"$/, "")
|
@@ -40,9 +42,28 @@ module Metanorma
|
|
40
42
|
tail and elem << tail
|
41
43
|
end
|
42
44
|
|
45
|
+
LOCALITY_REGEX_STR_TRIPLEDASH = <<~REGEXP.freeze
|
46
|
+
^(?<locality>(#{CONN_REGEX_STR})?
|
47
|
+
(#{LOCALITIES})(\\s+|=))
|
48
|
+
(?<ref>[^"][^ \\t\\n,:;-]*
|
49
|
+
-[^ \\t\\n,:;"-]+
|
50
|
+
-[^ \\t\\n,:;"]+)
|
51
|
+
(?<text>[,:;]?\\s*
|
52
|
+
.*)$
|
53
|
+
REGEXP
|
54
|
+
|
55
|
+
# treat n-n-n locality as "n-n-n", do not parse as a range
|
56
|
+
def locality_normalise(text)
|
57
|
+
re = to_regex(LOCALITY_REGEX_STR_TRIPLEDASH)
|
58
|
+
m = re.match(text) and
|
59
|
+
text = %(#{m[:locality]}"#{m[:ref]}"#{m[:text]})
|
60
|
+
text
|
61
|
+
end
|
62
|
+
|
43
63
|
def extract_localities1(elem, text)
|
44
|
-
|
45
|
-
|
64
|
+
re = to_regex(LOCALITY_REGEX_STR)
|
65
|
+
b = elem.add_child("<localityStack/>").first if re.match text
|
66
|
+
while (m = re.match locality_normalise(text))
|
46
67
|
add_locality(b, m)
|
47
68
|
text = extract_localities_update_text(m)
|
48
69
|
b = elem.add_child("<localityStack/>").first if m[:punct] == ";"
|
@@ -54,7 +75,8 @@ module Metanorma
|
|
54
75
|
# clause=3;and!5 => clause=3;and!clause=5
|
55
76
|
def extract_localities_update_text(match)
|
56
77
|
ret = match[:text]
|
57
|
-
|
78
|
+
re = to_regex(LOCALITY_REGEX_VALUE_ONLY_STR)
|
79
|
+
if re.match?(ret) && match[:punct] == ";"
|
58
80
|
ret.sub!(%r{^(#{CONN_REGEX_STR})}o, "\\1#{match[:locality]}=")
|
59
81
|
end
|
60
82
|
ret
|
@@ -11,7 +11,6 @@ module Metanorma
|
|
11
11
|
def metadata_id(node, xml)
|
12
12
|
id = node.attr("docidentifier") || metadata_id_build(node)
|
13
13
|
xml.docidentifier id
|
14
|
-
xml.docnumber node.attr("docnumber")
|
15
14
|
end
|
16
15
|
|
17
16
|
def metadata_id_build(node)
|
@@ -25,6 +24,11 @@ module Metanorma
|
|
25
24
|
def metadata_other_id(node, xml)
|
26
25
|
a = node.attr("isbn") and xml.docidentifier a, type: "ISBN"
|
27
26
|
a = node.attr("isbn10") and xml.docidentifier a, type: "ISBN10"
|
27
|
+
csv_split(node.attr("docidentifier-additional"), ",")&.each do |n|
|
28
|
+
t, v = n.split(":", 2)
|
29
|
+
xml.docidentifier v, type: t
|
30
|
+
end
|
31
|
+
xml.docnumber node.attr("docnumber")
|
28
32
|
end
|
29
33
|
|
30
34
|
def metadata_version(node, xml)
|
@@ -44,8 +48,7 @@ module Metanorma
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def metadata_committee(node, xml)
|
47
|
-
|
48
|
-
|
51
|
+
node.attr("technical-committee") or return
|
49
52
|
xml.editorialgroup do |a|
|
50
53
|
committee_component("technical-committee", node, a)
|
51
54
|
end
|
@@ -64,12 +67,9 @@ module Metanorma
|
|
64
67
|
|
65
68
|
def metadata_source(node, xml)
|
66
69
|
node.attr("uri") && xml.uri(node.attr("uri"))
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
node.attr("doc-uri") && xml.uri(node.attr("doc-uri"), type: "doc")
|
71
|
-
node.attr("relaton-uri") && xml.uri(node.attr("relaton-uri"),
|
72
|
-
type: "relaton")
|
70
|
+
%w(xml html pdf doc relaton).each do |t|
|
71
|
+
node.attr("#{t}-uri") && xml.uri(node.attr("#{t}-uri"), type: t)
|
72
|
+
end
|
73
73
|
end
|
74
74
|
|
75
75
|
def metadata_date1(node, xml, type)
|
@@ -88,8 +88,7 @@ module Metanorma
|
|
88
88
|
def metadata_date(node, xml)
|
89
89
|
datetypes.each { |t| metadata_date1(node, xml, t) }
|
90
90
|
node.attributes.each_key do |a|
|
91
|
-
|
92
|
-
|
91
|
+
a == "date" || /^date_\d+$/.match(a) or next
|
93
92
|
type, date = node.attr(a).split(/ /, 2)
|
94
93
|
type or next
|
95
94
|
xml.date type: type do |d|
|
@@ -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.
|
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>
|
@@ -17,16 +17,23 @@ module Metanorma
|
|
17
17
|
named :index
|
18
18
|
|
19
19
|
def preprocess_attrs(attrs)
|
20
|
-
return unless attrs.size > 1 && attrs.size < 5
|
21
|
-
|
22
20
|
ret = { primary: attrs[1], target: attrs[attrs.size] }
|
23
21
|
ret[:secondary] = attrs[2] if attrs.size > 2
|
24
22
|
ret[:tertiary] = attrs[3] if attrs.size > 3
|
25
23
|
ret
|
26
24
|
end
|
27
25
|
|
28
|
-
def
|
29
|
-
|
26
|
+
def validate(parent, target, attrs)
|
27
|
+
attrs.size > 1 && attrs.size < 5 and return true
|
28
|
+
e = "invalid index \"#{target}\" cross-reference: wrong number of " \
|
29
|
+
"attributes in `index:#{target}[#{attrs.values.join(',')}]`"
|
30
|
+
parent.converter.log.add("Index", parent, e, severity: 0)
|
31
|
+
false
|
32
|
+
end
|
33
|
+
|
34
|
+
def process(parent, target, attr)
|
35
|
+
validate(parent, target, attr) or return
|
36
|
+
args = preprocess_attrs(attr)
|
30
37
|
ret = "<index-xref also='#{target == 'also'}'>" \
|
31
38
|
"<primary>#{args[:primary]}</primary>"
|
32
39
|
ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
|
@@ -17,6 +17,7 @@ module Metanorma
|
|
17
17
|
|
18
18
|
def isorefrender1(bib, match, code, year, allp = "")
|
19
19
|
bib.title(**plaintxt) { |i| i << ref_normalise(match[:text]) }
|
20
|
+
#refitem_render_formattedref(bib, match[:text])
|
20
21
|
docid(bib, match[:usrlbl]) if match[:usrlbl]
|
21
22
|
docid(bib, code[:usrlabel]) if code && code[:usrlabel]
|
22
23
|
docid(bib, id_and_year(match[:code], year) + allp)
|
@@ -28,7 +29,7 @@ module Metanorma
|
|
28
29
|
yr = norm_year(match[:year])
|
29
30
|
{ code: match[:code], year: yr, match: match,
|
30
31
|
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel],
|
31
|
-
analyse_code: code, lang:
|
32
|
+
analyse_code: code, lang: @lang || :all }
|
32
33
|
end
|
33
34
|
|
34
35
|
def isorefmatchesout(item, xml)
|
@@ -47,7 +48,7 @@ module Metanorma
|
|
47
48
|
|
48
49
|
def isorefmatches2code(match, _item)
|
49
50
|
code = analyse_ref_code(match[:code])
|
50
|
-
{ code: match[:code], no_year: true, lang:
|
51
|
+
{ code: match[:code], no_year: true, lang: @lang || :all,
|
51
52
|
note: match[:fn], year: nil, match: match, analyse_code: code,
|
52
53
|
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel] }
|
53
54
|
end
|
@@ -79,7 +80,7 @@ module Metanorma
|
|
79
80
|
yr = norm_year(match[:year])
|
80
81
|
hasyr = !yr.nil? && yr != "--"
|
81
82
|
{ code: match[:code], match: match, yr: yr, hasyr: hasyr,
|
82
|
-
year: hasyr ? yr : nil, lang:
|
83
|
+
year: hasyr ? yr : nil, lang: @lang || :all,
|
83
84
|
all_parts: true, no_year: yr == "--",
|
84
85
|
title: match[:text], usrlbl: match[:usrlbl] || code[:usrlabel] }
|
85
86
|
end
|
@@ -125,11 +126,10 @@ module Metanorma
|
|
125
126
|
|
126
127
|
def refitem_render(xml, match, code)
|
127
128
|
xml.bibitem **attr_code(
|
128
|
-
id: match[:anchor], suppress_identifier: code[:dropid],
|
129
|
+
id: match[:anchor], suppress_identifier: code[:dropid],
|
130
|
+
hidden: code[:hidden]
|
129
131
|
) do |t|
|
130
|
-
t
|
131
|
-
i << ref_normalise_no_format(match[:text])
|
132
|
-
end
|
132
|
+
refitem_render_formattedref(t, match[:text])
|
133
133
|
yr_match = refitem1yr(code[:id])
|
134
134
|
refitem_render1(match, code, t)
|
135
135
|
/^\d+$|^\(.+\)$/.match?(code[:id]) or
|
@@ -138,11 +138,19 @@ module Metanorma
|
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
141
|
+
def refitem_render_formattedref(bibitem, title)
|
142
|
+
(title.nil? || title.empty?) and title = @i18n.no_information_available
|
143
|
+
bibitem.formattedref format: "application/x-isodoc+xml" do |i|
|
144
|
+
i << ref_normalise_no_format(title)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
141
148
|
# TODO: alternative where only title is available
|
142
149
|
def refitemcode(item, node)
|
143
150
|
m = NON_ISO_REF.match(item) and return refitem1code(item, m).compact
|
144
151
|
m = NON_ISO_REF1.match(item) and return refitem1code(item, m).compact
|
145
|
-
@log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}",
|
152
|
+
@log.add("AsciiDoc Input", node, "#{MALFORMED_REF}: #{item}",
|
153
|
+
severity: 1)
|
146
154
|
{}
|
147
155
|
end
|
148
156
|
|
@@ -154,7 +162,7 @@ module Metanorma
|
|
154
162
|
{ code: code[:id], analyse_code: code, localfile: code[:localfile],
|
155
163
|
year: (m = refitem1yr(code[:id])) ? m[:year] : nil,
|
156
164
|
title: match[:text], match: match, hidden: code[:hidden],
|
157
|
-
usrlbl: match[:usrlbl] || code[:usrlabel], lang:
|
165
|
+
usrlbl: match[:usrlbl] || code[:usrlabel], lang: @lang || :all }
|
158
166
|
end
|
159
167
|
|
160
168
|
def refitem1yr(code)
|
@@ -71,13 +71,14 @@ module Metanorma
|
|
71
71
|
# supply title if missing;
|
72
72
|
# add title with spans in it as formattedref, to emend bibitem with later
|
73
73
|
def emend_biblio_title(xml, code, title)
|
74
|
+
fmt = /<span class=|<fn/.match?(title)
|
74
75
|
unless xml.at("/bibitem/title[text()]")
|
75
76
|
@log.add("Bibliography", nil,
|
76
77
|
"ERROR: No title retrieved for #{code}")
|
78
|
+
!fmt and
|
77
79
|
xml.root << "<title>#{title || '(MISSING TITLE)'}</title>"
|
78
80
|
end
|
79
|
-
|
80
|
-
xml.root << "<formattedref>#{title}</formattedref>"
|
81
|
+
fmt and xml.root << "<formattedref>#{title}</formattedref>"
|
81
82
|
end
|
82
83
|
|
83
84
|
def emend_biblio_usrlbl(xml, usrlbl)
|
@@ -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
|
-
|
28
|
-
|
29
|
-
|
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
|
-
|
99
|
-
|
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] =
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
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
|
-
|
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)
|
245
|
-
|
246
|
-
|
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(
|
68
|
-
|
69
|
-
|
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
|
|
data/metanorma-standoc.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "addressable", "~> 2.8.0"
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "iev", "~> 0.3.0"
|
34
|
-
spec.add_dependency "isodoc", "~> 2.8.
|
34
|
+
spec.add_dependency "isodoc", "~> 2.8.3"
|
35
35
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
36
36
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
|
@@ -42,9 +42,8 @@ Gem::Specification.new do |spec|
|
|
42
42
|
spec.add_dependency "concurrent-ruby"
|
43
43
|
spec.add_dependency "pngcheck"
|
44
44
|
spec.add_dependency "relaton-cli", "~> 1.18.0"
|
45
|
-
spec.add_dependency "relaton-iev", "~> 1.
|
45
|
+
spec.add_dependency "relaton-iev", "~> 1.2.0"
|
46
46
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
47
|
-
spec.add_dependency "vectory", "~> 0.6"
|
48
47
|
|
49
48
|
spec.add_development_dependency "debug"
|
50
49
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
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.
|
4
|
+
version: 2.8.2
|
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-
|
11
|
+
date: 2024-02-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.8.
|
61
|
+
version: 2.8.3
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.8.
|
68
|
+
version: 2.8.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: metanorma
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,14 +198,14 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: 1.
|
201
|
+
version: 1.2.0
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: 1.
|
208
|
+
version: 1.2.0
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: unicode2latex
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,20 +220,6 @@ dependencies:
|
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: 0.0.1
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: vectory
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - "~>"
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0.6'
|
230
|
-
type: :runtime
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - "~>"
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0.6'
|
237
223
|
- !ruby/object:Gem::Dependency
|
238
224
|
name: debug
|
239
225
|
requirement: !ruby/object:Gem::Requirement
|