metanorma-standoc 2.8.1 → 2.8.3
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/biblio.rng +28 -25
- data/lib/metanorma/standoc/cleanup.rb +11 -3
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +37 -8
- data/lib/metanorma/standoc/cleanup_table.rb +2 -4
- data/lib/metanorma/standoc/cleanup_xref.rb +32 -10
- data/lib/metanorma/standoc/converter.rb +8 -0
- data/lib/metanorma/standoc/datamodel/attributes_table_preprocessor.rb +2 -2
- data/lib/metanorma/standoc/datamodel/diagram_preprocessor.rb +2 -2
- data/lib/metanorma/standoc/front.rb +10 -11
- data/lib/metanorma/standoc/front_contributor.rb +2 -0
- data/lib/metanorma/standoc/front_organisation.rb +39 -7
- data/lib/metanorma/standoc/macros.rb +7 -7
- data/lib/metanorma/standoc/macros_embed.rb +15 -5
- 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/utils.rb +7 -6
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +5 -6
- metadata +14 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76c0e218fd82abc53141b42753ee4cbc14956ee9ccc75f1e8115bf91ac6a0eb6
|
4
|
+
data.tar.gz: 532c96be450bb8f4a234ec5f6cd6c032d71fe89e20ad46e1f48195137b108c94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab6d097fc885f64299d90ceed88dc475c951ff7c916f176e504aaca63336b69e62bb12c48059004fe757200a448a15fd4c798ffcd2e7f9b7c04444259431799
|
7
|
+
data.tar.gz: 6acb021a5f5348caa7c625db4d54a9a2af9e26e1720318cdd77a54c77bc0c734109c600d96a95d2a5a161bc5eb28f6db2336f06dee75bd896733fef8a600f1bf
|
@@ -338,29 +338,32 @@
|
|
338
338
|
</define>
|
339
339
|
<define name="organization">
|
340
340
|
<element name="organization">
|
341
|
-
<
|
342
|
-
<ref name="orgname"/>
|
343
|
-
</oneOrMore>
|
344
|
-
<zeroOrMore>
|
345
|
-
<ref name="subdivision"/>
|
346
|
-
</zeroOrMore>
|
347
|
-
<optional>
|
348
|
-
<ref name="abbreviation"/>
|
349
|
-
</optional>
|
350
|
-
<zeroOrMore>
|
351
|
-
<ref name="uri"/>
|
352
|
-
</zeroOrMore>
|
353
|
-
<zeroOrMore>
|
354
|
-
<ref name="org-identifier"/>
|
355
|
-
</zeroOrMore>
|
356
|
-
<zeroOrMore>
|
357
|
-
<ref name="contact"/>
|
358
|
-
</zeroOrMore>
|
359
|
-
<optional>
|
360
|
-
<ref name="logo"/>
|
361
|
-
</optional>
|
341
|
+
<ref name="OrganizationType"/>
|
362
342
|
</element>
|
363
343
|
</define>
|
344
|
+
<define name="OrganizationType">
|
345
|
+
<oneOrMore>
|
346
|
+
<ref name="orgname"/>
|
347
|
+
</oneOrMore>
|
348
|
+
<zeroOrMore>
|
349
|
+
<ref name="subdivision"/>
|
350
|
+
</zeroOrMore>
|
351
|
+
<optional>
|
352
|
+
<ref name="abbreviation"/>
|
353
|
+
</optional>
|
354
|
+
<zeroOrMore>
|
355
|
+
<ref name="uri"/>
|
356
|
+
</zeroOrMore>
|
357
|
+
<zeroOrMore>
|
358
|
+
<ref name="org-identifier"/>
|
359
|
+
</zeroOrMore>
|
360
|
+
<zeroOrMore>
|
361
|
+
<ref name="contact"/>
|
362
|
+
</zeroOrMore>
|
363
|
+
<optional>
|
364
|
+
<ref name="logo"/>
|
365
|
+
</optional>
|
366
|
+
</define>
|
364
367
|
<define name="orgname">
|
365
368
|
<element name="name">
|
366
369
|
<choice>
|
@@ -371,10 +374,10 @@
|
|
371
374
|
</define>
|
372
375
|
<define name="subdivision">
|
373
376
|
<element name="subdivision">
|
374
|
-
<
|
375
|
-
<
|
376
|
-
|
377
|
-
|
377
|
+
<optional>
|
378
|
+
<attribute name="type"/>
|
379
|
+
</optional>
|
380
|
+
<ref name="OrganizationType"/>
|
378
381
|
</element>
|
379
382
|
</define>
|
380
383
|
<define name="logo">
|
@@ -53,15 +53,16 @@ module Metanorma
|
|
53
53
|
normref_cleanup(xmldoc)
|
54
54
|
biblio_cleanup(xmldoc)
|
55
55
|
reference_names(xmldoc)
|
56
|
-
asciimath_cleanup(xmldoc) # feeds: mathml_cleanup, termdef_cleanup,
|
56
|
+
asciimath_cleanup(xmldoc) # feeds: mathml_cleanup, termdef_cleanup,
|
57
|
+
# symbols_cleanup
|
57
58
|
symbols_cleanup(xmldoc) # feeds: termdef_cleanup
|
58
59
|
xref_cleanup(xmldoc) # feeds: concept_cleanup, origin_cleanup
|
59
60
|
concept_cleanup(xmldoc) # feeds: related_cleanup, termdef_cleanup
|
60
61
|
related_cleanup(xmldoc) # feeds: termdef_cleanup
|
61
62
|
origin_cleanup(xmldoc) # feeds: termdef_cleanup
|
62
63
|
bookmark_cleanup(xmldoc)
|
63
|
-
termdef_cleanup(xmldoc) # feeds:
|
64
|
-
|
64
|
+
termdef_cleanup(xmldoc) # feeds: relaton_iev_cleanup, term_index_cleanup
|
65
|
+
relaton_iev_cleanup(xmldoc)
|
65
66
|
element_name_cleanup(xmldoc)
|
66
67
|
term_index_cleanup(xmldoc)
|
67
68
|
bpart_cleanup(xmldoc)
|
@@ -88,6 +89,13 @@ module Metanorma
|
|
88
89
|
xmldoc
|
89
90
|
end
|
90
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
|
+
|
91
99
|
def docidentifier_cleanup(xmldoc); end
|
92
100
|
|
93
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>
|
@@ -22,8 +22,7 @@ module Metanorma
|
|
22
22
|
|
23
23
|
def insert_thead(table)
|
24
24
|
thead = table.at("./thead")
|
25
|
-
|
26
|
-
|
25
|
+
thead.nil? or return thead
|
27
26
|
if tname = table.at("./name")
|
28
27
|
thead = tname.add_next_sibling("<thead/>").first
|
29
28
|
return thead
|
@@ -35,8 +34,7 @@ module Metanorma
|
|
35
34
|
xmldoc.xpath("//table[@headerrows]").each do |s|
|
36
35
|
thead = insert_thead(s)
|
37
36
|
(thead.xpath("./tr").size...s["headerrows"].to_i).each do
|
38
|
-
|
39
|
-
row.parent = thead
|
37
|
+
s.at("./tbody/tr").parent = thead
|
40
38
|
end
|
41
39
|
thead.xpath(".//td").each { |n| n.name = "th" }
|
42
40
|
s.delete("headerrows")
|
@@ -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
|
@@ -21,6 +21,14 @@ module Metanorma
|
|
21
21
|
# schema encapsulation of the document for validation
|
22
22
|
class Converter
|
23
23
|
Asciidoctor::Extensions.register do
|
24
|
+
preprocessor Metanorma::Plugin::Lutaml::LutamlPreprocessor
|
25
|
+
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlAttributesTablePreprocessor
|
26
|
+
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlDatamodelDescriptionPreprocessor
|
27
|
+
preprocessor Metanorma::Plugin::Lutaml::LutamlUmlClassPreprocessor
|
28
|
+
inline_macro Metanorma::Plugin::Lutaml::LutamlFigureInlineMacro
|
29
|
+
inline_macro Metanorma::Plugin::Lutaml::LutamlTableInlineMacro
|
30
|
+
block_macro Metanorma::Plugin::Lutaml::LutamlDiagramBlockMacro
|
31
|
+
block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
|
24
32
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
25
33
|
preprocessor Metanorma::Standoc::LinkProtectPreprocessor
|
26
34
|
preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
|
@@ -14,8 +14,8 @@ module Metanorma
|
|
14
14
|
# read include derectives that goes after that in block and transform
|
15
15
|
# into yaml2text blocks
|
16
16
|
def process(document, reader)
|
17
|
-
input_lines = reader.
|
18
|
-
Asciidoctor::
|
17
|
+
input_lines = reader.lines.to_enum
|
18
|
+
Asciidoctor::PreprocessorReader.new(document, processed_lines(document, input_lines))
|
19
19
|
end
|
20
20
|
|
21
21
|
private
|
@@ -15,8 +15,8 @@ module Metanorma
|
|
15
15
|
# read include derectives that goes after that in block and transform
|
16
16
|
# into plantuml block
|
17
17
|
def process(document, reader)
|
18
|
-
input_lines = reader.
|
19
|
-
Asciidoctor::
|
18
|
+
input_lines = reader.lines.to_enum
|
19
|
+
Asciidoctor::PreprocessorReader.new(document, processed_lines(document, input_lines))
|
20
20
|
end
|
21
21
|
|
22
22
|
private
|
@@ -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|
|
@@ -13,16 +13,48 @@ module Metanorma
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
def organization(org, orgname, node = nil, default_org = nil)
|
16
|
+
def organization(org, orgname, node = nil, default_org = nil, attrs = {})
|
17
17
|
abbrevs = org_abbrev
|
18
18
|
n = abbrevs.invert[orgname] and orgname = n
|
19
19
|
org.name orgname
|
20
|
-
default_org
|
20
|
+
default_org && (a = node&.attr("subdivision")) && !attrs[:subdiv] and
|
21
|
+
subdivision(a, node&.attr("subdivision-abbr"), org)
|
22
|
+
a = attrs[:subdiv] and subdivision(a, nil, org)
|
21
23
|
abbr = org_abbrev[orgname]
|
22
|
-
default_org && b = node&.attr("subdivision-abbr") and abbr = b
|
23
24
|
abbr and org.abbreviation abbr
|
24
25
|
end
|
25
26
|
|
27
|
+
def subdivision(attr, abbr, org)
|
28
|
+
abbrs = csv_split(abbr) || []
|
29
|
+
subdivs = csv_split(attr, ";")
|
30
|
+
subdivs.size == abbrs.size or abbrs = []
|
31
|
+
subdivs.each_with_index do |s, i|
|
32
|
+
subdivision1(s, abbrs[i], org)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def subdivision1(attr, abbr, org)
|
37
|
+
m = csv_split(attr, ",").map do |s1|
|
38
|
+
t, v = s1.split(":", 2).map(&:strip)
|
39
|
+
if v.nil?
|
40
|
+
v = t
|
41
|
+
t = nil
|
42
|
+
end
|
43
|
+
{ type: t, value: v }
|
44
|
+
end
|
45
|
+
abbr and m[0][:abbr] = abbr
|
46
|
+
subdiv_build(m, org)
|
47
|
+
end
|
48
|
+
|
49
|
+
def subdiv_build(list, org)
|
50
|
+
list.empty? and return
|
51
|
+
org.subdivision **attr_code(type: list[0][:type]) do |s|
|
52
|
+
s.name { |n| n << list[0][:value] }
|
53
|
+
subdiv_build(list[1..-1], s)
|
54
|
+
a = list[0][:abbr] and s.abbreviation { |n| n << a }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
26
58
|
def org_address(org, xml)
|
27
59
|
p = org[:address] and xml.address do |ad|
|
28
60
|
ad.formattedAddress do |f|
|
@@ -43,9 +75,8 @@ module Metanorma
|
|
43
75
|
xml.name node.attr("affiliation#{suffix}")
|
44
76
|
abbr = node.attr("affiliation_abbrev#{suffix}") and
|
45
77
|
xml.abbreviation abbr
|
46
|
-
|
47
|
-
|
48
|
-
end
|
78
|
+
a = node.attr("affiliation_subdiv#{suffix}") and
|
79
|
+
subdivision(a, nil, xml)
|
49
80
|
person_address(node, suffix, xml)
|
50
81
|
person_org_logo(node, suffix, xml)
|
51
82
|
end
|
@@ -108,7 +139,7 @@ module Metanorma
|
|
108
139
|
end
|
109
140
|
|
110
141
|
def org_organization(node, xml, org)
|
111
|
-
organization(xml, org[:name], node, !node.attr("publisher"))
|
142
|
+
organization(xml, org[:name], node, !node.attr("publisher"), org)
|
112
143
|
org_address(org, xml)
|
113
144
|
org_logo(xml, org[:logo])
|
114
145
|
end
|
@@ -150,6 +181,7 @@ module Metanorma
|
|
150
181
|
def extract_org_attrs_complex(node, opts, source, suffix)
|
151
182
|
{ name: node.attr(source + suffix),
|
152
183
|
role: opts[:role], desc: opts[:desc],
|
184
|
+
subdiv: node.attr("#{source}_subdivision#{suffix}"),
|
153
185
|
logo: node.attr("#{source}_logo#{suffix}") }.compact
|
154
186
|
.merge(extract_org_attrs_address(node, opts, suffix))
|
155
187
|
end
|
@@ -50,14 +50,14 @@ module Metanorma
|
|
50
50
|
end
|
51
51
|
|
52
52
|
class NamedEscapePreprocessor < Asciidoctor::Extensions::Preprocessor
|
53
|
-
def process(
|
53
|
+
def process(document, reader)
|
54
54
|
c = HTMLEntities.new
|
55
|
-
lines = reader.
|
56
|
-
l.split(/(&[A-Za-z][
|
55
|
+
lines = reader.lines.map do |l|
|
56
|
+
l.split(/(&[A-Za-z][^&;]*;)/).map do |s|
|
57
57
|
/^&[A-Za-z]/.match?(s) ? c.encode(c.decode(s), :hexadecimal) : s
|
58
58
|
end.join
|
59
59
|
end
|
60
|
-
::Asciidoctor::
|
60
|
+
::Asciidoctor::PreprocessorReader.new document, lines
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -85,14 +85,14 @@ module Metanorma
|
|
85
85
|
delimln: delimln }
|
86
86
|
end
|
87
87
|
|
88
|
-
def process(
|
88
|
+
def process(document, reader)
|
89
89
|
p = init
|
90
|
-
lines = reader.
|
90
|
+
lines = reader.lines.map do |t|
|
91
91
|
p = pass_status(p, t.rstrip)
|
92
92
|
!p[:pass] && t.include?(":") and t = inlinelinkmacro(inlinelink(t))
|
93
93
|
t
|
94
94
|
end
|
95
|
-
::Asciidoctor::
|
95
|
+
::Asciidoctor::PreprocessorReader.new document, lines
|
96
96
|
end
|
97
97
|
|
98
98
|
def pass_status(status, text)
|
@@ -1,13 +1,22 @@
|
|
1
1
|
require "pathname"
|
2
2
|
|
3
|
+
module Asciidoctor
|
4
|
+
class PreprocessorNoIfdefsReader < PreprocessorReader
|
5
|
+
def preprocess_conditional_directive(keyword, target, delimiter, text)
|
6
|
+
false # decline to resolve idefs
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
3
11
|
module Metanorma
|
4
12
|
module Standoc
|
5
13
|
class EmbedIncludeProcessor < Asciidoctor::Extensions::Preprocessor
|
6
14
|
def process(doc, reader)
|
7
15
|
reader.eof? and return reader
|
8
|
-
|
16
|
+
r = ::Asciidoctor::PreprocessorNoIfdefsReader.new doc, reader.lines
|
17
|
+
lines = r.readlines
|
9
18
|
headings = lines.grep(/^== /).map(&:strip)
|
10
|
-
ret = lines.each_with_object(embed_acc(doc,
|
19
|
+
ret = lines.each_with_object(embed_acc(doc, r)) do |line, m|
|
11
20
|
process_line(line, m, headings)
|
12
21
|
end
|
13
22
|
return_to_document(doc, ret)
|
@@ -37,7 +46,8 @@ module Metanorma
|
|
37
46
|
ret.reverse.each do |l|
|
38
47
|
if l[:file]
|
39
48
|
new = Pathname.new(l[:path]).relative_path_from(b).to_s
|
40
|
-
reader.push_include l[:lines], new, l[:path]
|
49
|
+
#reader.push_include l[:lines], new, l[:path]
|
50
|
+
reader.unshift_lines l[:lines]
|
41
51
|
else reader.unshift_lines l[:lines]
|
42
52
|
end
|
43
53
|
end
|
@@ -120,8 +130,8 @@ module Metanorma
|
|
120
130
|
lines = filter_sections(read(inc_path), headings)
|
121
131
|
n = Asciidoctor::Document
|
122
132
|
.new [], { safe: :safe, base_dir: File.dirname(inc_path) }
|
123
|
-
r = ::Asciidoctor::
|
124
|
-
ret = embed_acc(n, r).merge(strip_header(r.
|
133
|
+
r = ::Asciidoctor::PreprocessorNoIfdefsReader.new n, lines
|
134
|
+
ret = embed_acc(n, r).merge(strip_header(r.readlines))
|
125
135
|
.merge(file: fname, path: inc_path, orig: acc[:orig])
|
126
136
|
ret[:hdr] or
|
127
137
|
raise "Embedding an incomplete document with no header: #{ret[:path]}"
|
@@ -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)
|
@@ -26,7 +26,8 @@ module Metanorma
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def csv_split(text, delim = ";")
|
29
|
-
Metanorma::Utils::csv_split(text, delim)
|
29
|
+
Metanorma::Utils::csv_split(@c.decode(text), delim)
|
30
|
+
.map { |x| @c.encode(x, :basic, :hexadecimal) }
|
30
31
|
end
|
31
32
|
|
32
33
|
def wrap_in_para(node, out)
|
@@ -69,11 +70,11 @@ module Metanorma
|
|
69
70
|
end
|
70
71
|
|
71
72
|
def xml_encode(text)
|
72
|
-
@c.encode(text, :basic, :hexadecimal)
|
73
|
-
gsub("&gt;", ">").gsub("&lt;", "<").gsub("&amp;", "&")
|
74
|
-
gsub(">", ">").gsub("<", "<").gsub("&", "&")
|
75
|
-
gsub(""", '"').gsub("
", "\n").gsub("&#", "&#")
|
76
|
-
gsub("'", "'")
|
73
|
+
@c.encode(text, :basic, :hexadecimal)
|
74
|
+
.gsub("&gt;", ">").gsub("&lt;", "<").gsub("&amp;", "&")
|
75
|
+
.gsub(">", ">").gsub("<", "<").gsub("&", "&")
|
76
|
+
.gsub(""", '"').gsub("
", "\n").gsub("&#", "&#")
|
77
|
+
.gsub("'", "'")
|
77
78
|
end
|
78
79
|
|
79
80
|
# wrapped in <sections>
|
data/metanorma-standoc.gemspec
CHANGED
@@ -31,20 +31,19 @@ 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.
|
34
|
+
spec.add_dependency "isodoc", "~> 2.9.0"
|
35
35
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
36
|
-
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.
|
37
|
-
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.
|
38
|
-
spec.add_dependency "metanorma-plugin-lutaml"
|
36
|
+
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
|
37
|
+
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
|
38
|
+
spec.add_dependency "metanorma-plugin-lutaml", "~> 0.5.0"
|
39
39
|
spec.add_dependency "ruby-jing"
|
40
40
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
41
41
|
spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
|
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.3
|
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-03-04 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.
|
61
|
+
version: 2.9.0
|
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.
|
68
|
+
version: 2.9.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: metanorma
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,42 +86,42 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.3.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.3.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: metanorma-plugin-glossarist
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
103
|
+
version: 0.2.0
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
110
|
+
version: 0.2.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: metanorma-plugin-lutaml
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 0.5.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 0.5.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: ruby-jing
|
127
127
|
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
|