metanorma-standoc 3.1.10 → 3.2.1
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 +3 -2
- data/lib/metanorma/standoc/base.rb +2 -2
- data/lib/metanorma/standoc/biblio.rng +4 -4
- data/lib/metanorma/standoc/blocks.rb +4 -8
- data/lib/metanorma/standoc/cleanup.rb +31 -61
- data/lib/metanorma/standoc/cleanup_asciibib.rb +7 -10
- data/lib/metanorma/standoc/cleanup_attachment.rb +1 -2
- data/lib/metanorma/standoc/cleanup_bibdata.rb +9 -0
- data/lib/metanorma/standoc/cleanup_bibitem.rb +29 -2
- data/lib/metanorma/standoc/cleanup_block.rb +1 -2
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +1 -2
- data/lib/metanorma/standoc/cleanup_footnotes.rb +1 -2
- data/lib/metanorma/standoc/cleanup_inline.rb +44 -4
- data/lib/metanorma/standoc/cleanup_maths.rb +3 -3
- data/lib/metanorma/standoc/cleanup_section_names.rb +1 -0
- data/lib/metanorma/standoc/cleanup_terms_boilerplate.rb +1 -3
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +2 -3
- data/lib/metanorma/standoc/cleanup_xref.rb +14 -11
- data/lib/metanorma/standoc/converter.rb +7 -5
- data/lib/metanorma/standoc/front.rb +27 -25
- data/lib/metanorma/standoc/front_committee.rb +5 -5
- data/lib/metanorma/standoc/front_contributor.rb +14 -14
- data/lib/metanorma/standoc/front_ext.rb +7 -5
- data/lib/metanorma/standoc/front_organisation.rb +16 -21
- data/lib/metanorma/standoc/init.rb +31 -5
- data/lib/metanorma/standoc/inline.rb +31 -12
- data/lib/metanorma/standoc/isodoc.rng +27 -10
- data/lib/metanorma/standoc/lists.rb +1 -1
- data/lib/metanorma/standoc/localbib.rb +5 -9
- data/lib/metanorma/standoc/log.rb +207 -0
- data/lib/metanorma/standoc/macros_embed.rb +5 -3
- data/lib/metanorma/standoc/macros_link.rb +2 -3
- data/lib/metanorma/standoc/macros_terms.rb +2 -0
- data/lib/metanorma/standoc/ref.rb +12 -13
- data/lib/metanorma/standoc/ref_queue.rb +4 -6
- data/lib/metanorma/standoc/ref_sect.rb +3 -6
- data/lib/metanorma/standoc/ref_utility.rb +4 -13
- data/lib/metanorma/standoc/section.rb +3 -9
- data/lib/metanorma/standoc/spans_to_bibitem.rb +12 -1
- data/lib/metanorma/standoc/spans_to_bibitem_preprocessing.rb +11 -7
- data/lib/metanorma/standoc/table.rb +1 -1
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +7 -18
- data/lib/metanorma/standoc/terms.rb +2 -4
- data/lib/metanorma/standoc/utils.rb +27 -2
- data/lib/metanorma/standoc/validate.rb +9 -17
- data/lib/metanorma/standoc/validate_image.rb +52 -9
- data/lib/metanorma/standoc/validate_schema.rb +3 -2
- data/lib/metanorma/standoc/validate_section.rb +3 -6
- data/lib/metanorma/standoc/validate_table.rb +3 -5
- data/lib/metanorma/standoc/validate_term.rb +4 -14
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +5 -3
- metadata +49 -20
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
module Metanorma
|
|
2
|
+
module Standoc
|
|
3
|
+
class Converter
|
|
4
|
+
# rubocop:disable Naming/VariableNumber
|
|
5
|
+
STANDOC_LOG_MESSAGES = {
|
|
6
|
+
"STANDOC_1": { category: "Include",
|
|
7
|
+
error: "Specified boilerplate file does not exist: %s",
|
|
8
|
+
severity: 0 },
|
|
9
|
+
"STANDOC_2": { category: "Table", error: "Empty table",
|
|
10
|
+
severity: 0 },
|
|
11
|
+
"STANDOC_3": { category: "Crossreferences",
|
|
12
|
+
error: "invalid index \"%s\" cross-reference: " \
|
|
13
|
+
"wrong number of attributes in `index:%s[%s]`",
|
|
14
|
+
severity: 0 },
|
|
15
|
+
"STANDOC_4": { category: "Table",
|
|
16
|
+
error: "Table rows in table %s: check rowspan",
|
|
17
|
+
severity: 0 },
|
|
18
|
+
"STANDOC_5": { category: "Table",
|
|
19
|
+
error: "Table exceeds maximum number of columns defined (%s)",
|
|
20
|
+
severity: 0 },
|
|
21
|
+
"STANDOC_6": { category: "Maths",
|
|
22
|
+
error: "Malformed MathML: %s\n%s",
|
|
23
|
+
severity: 0 },
|
|
24
|
+
"STANDOC_7": { category: "Metanorma XML Syntax", error: "%s",
|
|
25
|
+
severity: 2 },
|
|
26
|
+
"STANDOC_8": { category: "Anchors", error: "Malformed URI: %s",
|
|
27
|
+
severity: 0 },
|
|
28
|
+
"STANDOC_9": { category: "Bibliography",
|
|
29
|
+
error: "Attachment %s does not exist",
|
|
30
|
+
severity: 0 },
|
|
31
|
+
"STANDOC_10": { category: "Anchors",
|
|
32
|
+
error: "The following reference is missing an anchor:\n%s",
|
|
33
|
+
severity: 1 },
|
|
34
|
+
"STANDOC_11": { category: "Bibliography",
|
|
35
|
+
error: "Reference %s is missing a title",
|
|
36
|
+
severity: 1 },
|
|
37
|
+
"STANDOC_12": { category: "Bibliography",
|
|
38
|
+
error: "Reference %s is missing a document identifier (docid)",
|
|
39
|
+
severity: 1 },
|
|
40
|
+
"STANDOC_13": { category: "AsciiDoc Input",
|
|
41
|
+
error: "term reference not in expected format:%s",
|
|
42
|
+
severity: 1 },
|
|
43
|
+
"STANDOC_14": { category: "Style",
|
|
44
|
+
error: "Style override set for ordered list",
|
|
45
|
+
severity: 2 },
|
|
46
|
+
"STANDOC_15": { category: "Crossreferences",
|
|
47
|
+
error: "Could not resolve footnoteblock:[%s]",
|
|
48
|
+
severity: 1 },
|
|
49
|
+
"STANDOC_16": { category: "AsciiDoc Input",
|
|
50
|
+
error: "Section not marked up as [bibliography]!",
|
|
51
|
+
severity: 2 },
|
|
52
|
+
"STANDOC_17": { category: "Bibliography",
|
|
53
|
+
error: "ERROR: No document identifier retrieved for %s",
|
|
54
|
+
severity: 2 },
|
|
55
|
+
"STANDOC_18": { category: "Bibliography",
|
|
56
|
+
error: "ERROR: No title retrieved for %s", severity: 2 },
|
|
57
|
+
"STANDOC_19": { category: "Bibliography",
|
|
58
|
+
error: "Cannot find reference %s for local Relaton " \
|
|
59
|
+
"data source %s", severity: 0 },
|
|
60
|
+
"STANDOC_20": { category: "AsciiDoc Input",
|
|
61
|
+
error: "Metadata definition list does not follow a term designation",
|
|
62
|
+
severity: 2 },
|
|
63
|
+
"STANDOC_21": { category: "Terms",
|
|
64
|
+
error: "Removed duplicate designation %s",
|
|
65
|
+
severity: 2 },
|
|
66
|
+
"STANDOC_22": { category: "Bibliography",
|
|
67
|
+
error: "Term \"%s\" does not match IEV %s \"%s\"",
|
|
68
|
+
severity: 1 },
|
|
69
|
+
"STANDOC_23": { category: "Anchors",
|
|
70
|
+
error: "Concept cross-reference error: %s",
|
|
71
|
+
severity: 0 },
|
|
72
|
+
"STANDOC_24": { category: "Terms",
|
|
73
|
+
error: "Term %s occurs twice as preferred designation: %s",
|
|
74
|
+
severity: 1 },
|
|
75
|
+
"STANDOC_25": { category: "Terms", severity: 0,
|
|
76
|
+
error: <<~ERROR.freeze },
|
|
77
|
+
Clause not recognised as a term clause, but contains designation markup
|
|
78
|
+
(<code>preferred:[], admitted:[], alt:[], deprecated:[]</code>):<br/>
|
|
79
|
+
%s</br>
|
|
80
|
+
Ensure the parent clause is recognised as a terms clause by inserting <code>[heading=terms and definitions]</code> above the title,
|
|
81
|
+
in case the heading is not automatically recognised. See also <a href="https://www.metanorma.org/author/topics/sections/concepts/#clause-title">Metanorma documentation</a>.
|
|
82
|
+
ERROR
|
|
83
|
+
"STANDOC_26": { category: "AsciiDoc Input",
|
|
84
|
+
error: "Error: Symbol reference in `symbol[%s]` missing: \"%s\" is not defined in document",
|
|
85
|
+
severity: 1 },
|
|
86
|
+
"STANDOC_27": { category: "AsciiDoc Input",
|
|
87
|
+
error: "Error: Term reference to `%s` missing: \"%s\" is not defined in document%s",
|
|
88
|
+
severity: 1 },
|
|
89
|
+
"STANDOC_28": { category: "Crossreferences",
|
|
90
|
+
error: "term source %s not referenced",
|
|
91
|
+
severity: 1 },
|
|
92
|
+
"STANDOC_29": { category: "AsciiDoc Input",
|
|
93
|
+
error: "converter missing for %s node in Metanorma backend",
|
|
94
|
+
severity: 1 },
|
|
95
|
+
"STANDOC_30": { category: "Crossreferences",
|
|
96
|
+
error: "%s does not have a corresponding anchor ID in the bibliography!",
|
|
97
|
+
severity: 2 },
|
|
98
|
+
"STANDOC_31": { category: "Crossreferences",
|
|
99
|
+
error: "Illegal cross-reference connective: %s",
|
|
100
|
+
severity: 0 },
|
|
101
|
+
"STANDOC_32": { category: "Crossreferences",
|
|
102
|
+
error: "%s does not have a corresponding anchor ID in the bibliography!",
|
|
103
|
+
severity: 2 },
|
|
104
|
+
"STANDOC_33": { category: "Maths",
|
|
105
|
+
error: "Invalid MathML: %s\n %s%s",
|
|
106
|
+
severity: 0 },
|
|
107
|
+
"STANDOC_34": { category: "Style",
|
|
108
|
+
error: "There is an instance of %s nested within %s",
|
|
109
|
+
severity: 2 },
|
|
110
|
+
"STANDOC_35": { category: "Style",
|
|
111
|
+
error: "There is a crossreference to an instance of %s nested within %s: %s",
|
|
112
|
+
severity: 2 },
|
|
113
|
+
"STANDOC_36": { category: "Anchors",
|
|
114
|
+
error: "ID %s has already been used at line %s",
|
|
115
|
+
severity: 0 },
|
|
116
|
+
"STANDOC_37": { category: "Bibliography",
|
|
117
|
+
error: "Cannot process format %s for local Relaton data source %s",
|
|
118
|
+
severity: 0 },
|
|
119
|
+
"STANDOC_38": { category: "Anchors",
|
|
120
|
+
error: "Crossreference target %s is undefined",
|
|
121
|
+
severity: 1 },
|
|
122
|
+
"STANDOC_39": { category: "Blocks",
|
|
123
|
+
error: "%s is empty",
|
|
124
|
+
severity: 1 },
|
|
125
|
+
"STANDOC_40": { category: "Bibliography",
|
|
126
|
+
error: "Could not retrieve %s: no access to online site",
|
|
127
|
+
severity: 1 },
|
|
128
|
+
"STANDOC_41": { category: "Include",
|
|
129
|
+
error: "Unresolved directive %s",
|
|
130
|
+
severity: 0 },
|
|
131
|
+
"STANDOC_42": { category: "Metanorma XML Syntax",
|
|
132
|
+
error: "Invalid passthrough content: %s\n" \
|
|
133
|
+
"This is not valid Metanorma XML. If you intended a different format, such as HTML, you need to specify `format=` on the pass markup;\n" \
|
|
134
|
+
"refer to https://www.metanorma.org/author/topics/blocks/passthroughs/",
|
|
135
|
+
severity: 0 },
|
|
136
|
+
"STANDOC_43": { category: "AsciiDoc Input",
|
|
137
|
+
error: <<~REF.freeze, severity: 1 },
|
|
138
|
+
no anchor on reference, markup may be malformed: see
|
|
139
|
+
https://www.metanorma.org/author/topics/sections/bibliography/ ,
|
|
140
|
+
https://www.metanorma.org/author/iso/topics/markup/#bibliographies : %s
|
|
141
|
+
REF
|
|
142
|
+
"STANDOC_44": { category: "Images", error: "Image not found: %s",
|
|
143
|
+
severity: 0 },
|
|
144
|
+
"STANDOC_45": { category: "Images",
|
|
145
|
+
error: "Corrupt PNG image detected: %s",
|
|
146
|
+
severity: 2 },
|
|
147
|
+
"STANDOC_46": { category: "Images",
|
|
148
|
+
error: "Image too large for Data URI encoding: disable Data URI encoding (`:data-uri-image: false`), or set `:data-uri-maxsize: 0`",
|
|
149
|
+
severity: 0 },
|
|
150
|
+
"STANDOC_47": { category: "Crossreferences",
|
|
151
|
+
error: "mismatch of callouts (%s) and annotations (%s)",
|
|
152
|
+
severity: 0 },
|
|
153
|
+
"STANDOC_48": { category: "Style", error: "(generic warning) %s",
|
|
154
|
+
severity: 2 },
|
|
155
|
+
"STANDOC_49": { category: "Bibliography",
|
|
156
|
+
error: "Numeric reference in normative references",
|
|
157
|
+
severity: 1 },
|
|
158
|
+
"STANDOC_50": { category: "Fatal Error", error: "%s", severity: 0 },
|
|
159
|
+
"STANDOC_51": { category: "Maths",
|
|
160
|
+
error: "latexmlmath failed to process equation:\n%s",
|
|
161
|
+
severity: 1 },
|
|
162
|
+
"STANDOC_52": { category: "Bibliography",
|
|
163
|
+
error: "Bibliographic spans: %s",
|
|
164
|
+
severity: 0 },
|
|
165
|
+
"STANDOC_53": { category: "Bibliography",
|
|
166
|
+
error: "Bibliographic spans: %s",
|
|
167
|
+
severity: 1 },
|
|
168
|
+
"STANDOC_54": { category: "Bibliography",
|
|
169
|
+
error: "Cannot process file %s for local Relaton data source %s",
|
|
170
|
+
severity: 0 },
|
|
171
|
+
"STANDOC_55": { category: "Images",
|
|
172
|
+
error: "Corrupt SVG image detected, error found: %s %s%s%s",
|
|
173
|
+
severity: 2 },
|
|
174
|
+
"STANDOC_56": { category: "Images",
|
|
175
|
+
error: "Corrupt SVG image detected, could not be fixed: %s %s%s%s",
|
|
176
|
+
severity: 1 },
|
|
177
|
+
"STANDOC_57": { category: "Images",
|
|
178
|
+
error: "SVG image warning: %s %s%s%s",
|
|
179
|
+
severity: 3 },
|
|
180
|
+
"STANDOC_58": { category: "Images",
|
|
181
|
+
error: "Corrupt SVG image detected, fix attempted: %s %s: %s %s, Node: %s",
|
|
182
|
+
severity: 2 },
|
|
183
|
+
"RELATON_1": { category: "Relaton",
|
|
184
|
+
error: "(Error from Relaton) %s",
|
|
185
|
+
severity: 0 },
|
|
186
|
+
"RELATON_2": { category: "Relaton",
|
|
187
|
+
error: "(Error from Relaton) %s",
|
|
188
|
+
severity: 1 },
|
|
189
|
+
"RELATON_3": { category: "Relaton",
|
|
190
|
+
error: "(Error from Relaton) %s",
|
|
191
|
+
severity: 2 },
|
|
192
|
+
"RELATON_4": { category: "Relaton",
|
|
193
|
+
error: "(Error from Relaton) %s",
|
|
194
|
+
severity: 3 },
|
|
195
|
+
"RELATON_5": { category: "Relaton",
|
|
196
|
+
error: "(Error from Relaton IEV) %s",
|
|
197
|
+
severity: 0 },
|
|
198
|
+
|
|
199
|
+
}.freeze
|
|
200
|
+
# rubocop:enable Naming/VariableNumber
|
|
201
|
+
|
|
202
|
+
def log_messages
|
|
203
|
+
STANDOC_LOG_MESSAGES
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
end
|
|
@@ -15,8 +15,9 @@ module Asciidoctor
|
|
|
15
15
|
n = peek_line(true)
|
|
16
16
|
/^Unresolved directive in/.match?(n) and
|
|
17
17
|
@document.converter.log
|
|
18
|
-
&.add("
|
|
19
|
-
|
|
18
|
+
&.add("STANDOC_41", nil, params: [HTMLEntities.new.encode(
|
|
19
|
+
n.sub(/^Unresolved directive /, ""), :basic
|
|
20
|
+
)])
|
|
20
21
|
end
|
|
21
22
|
[inc_path, target_type, relpath]
|
|
22
23
|
end
|
|
@@ -86,7 +87,8 @@ module Metanorma
|
|
|
86
87
|
if l.is_a?(Hash)
|
|
87
88
|
acc, m = update_embeds(acc, m, emb)
|
|
88
89
|
flatten_embeds(l).each { |x| m << x }
|
|
89
|
-
else acc << l
|
|
90
|
+
else acc << l
|
|
91
|
+
end
|
|
90
92
|
end
|
|
91
93
|
acc, ret = update_embeds(acc, ret, emb)
|
|
92
94
|
ret
|
|
@@ -13,9 +13,8 @@ module Metanorma
|
|
|
13
13
|
|
|
14
14
|
def validate(parent, target, attrs)
|
|
15
15
|
attrs.size > 1 && attrs.size < 5 and return true
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
parent.converter.log.add("Crossreferences", parent, e, severity: 0)
|
|
16
|
+
parent.converter.log.add("STANDOC_3", parent,
|
|
17
|
+
params: [target, target, attrs.values.join(",")])
|
|
19
18
|
false
|
|
20
19
|
end
|
|
21
20
|
|
|
@@ -71,6 +71,7 @@ module Metanorma
|
|
|
71
71
|
named :term
|
|
72
72
|
name_positional_attributes "name", "termxref"
|
|
73
73
|
using_format :short
|
|
74
|
+
match /\\?(?<!\w)term:(){0}\[(|[^\]\\]*(?:\\.[^\]\\]*)*)\]/
|
|
74
75
|
|
|
75
76
|
def process(_parent, _target, attrs)
|
|
76
77
|
termref = attrs["termxref"] || attrs["name"]
|
|
@@ -84,6 +85,7 @@ module Metanorma
|
|
|
84
85
|
named :symbol
|
|
85
86
|
name_positional_attributes "name", "termxref"
|
|
86
87
|
using_format :short
|
|
88
|
+
match /\\?(?<!\w)symbol:(){0}\[(|[^\]\\]*(?:\\.[^\]\\]*)*)\]/
|
|
87
89
|
|
|
88
90
|
def process(_parent, _target, attrs)
|
|
89
91
|
termref = attrs["termxref"] || attrs["name"]
|
|
@@ -60,9 +60,8 @@ module Metanorma
|
|
|
60
60
|
|
|
61
61
|
def ref_fn(match, xml)
|
|
62
62
|
if match.names.include?("fn") && match[:fn]
|
|
63
|
-
xml
|
|
64
|
-
|
|
65
|
-
end
|
|
63
|
+
add_noko_elem(xml, "note", match[:fn].to_s,
|
|
64
|
+
**plaintxt.merge(type: "Unpublished-Status"))
|
|
66
65
|
end
|
|
67
66
|
end
|
|
68
67
|
|
|
@@ -115,17 +114,19 @@ module Metanorma
|
|
|
115
114
|
i = code[:id] and
|
|
116
115
|
docid(bib, /^\d+$/.match?(i) ? "[#{i}]" : i, code[:type])
|
|
117
116
|
code[:type] == "repo" and
|
|
118
|
-
bib
|
|
117
|
+
add_noko_elem(bib, "docidentifier", code[:key], type: "repository")
|
|
119
118
|
end
|
|
120
119
|
|
|
121
120
|
def refitem_uri(code, bib)
|
|
122
121
|
if code[:type] == "path"
|
|
123
|
-
bib
|
|
124
|
-
|
|
122
|
+
add_noko_elem(bib, "uri", code[:key].sub(/\.[a-zA-Z0-9]+$/, ""),
|
|
123
|
+
type: "URI")
|
|
124
|
+
add_noko_elem(bib, "uri", code[:key].sub(/\.[a-zA-Z0-9]+$/, ""),
|
|
125
|
+
type: "citation")
|
|
125
126
|
end
|
|
126
127
|
if code[:type] == "attachment"
|
|
127
|
-
bib
|
|
128
|
-
bib
|
|
128
|
+
add_noko_elem(bib, "uri", code[:key], type: "attachment")
|
|
129
|
+
add_noko_elem(bib, "uri", code[:key], type: "citation")
|
|
129
130
|
end
|
|
130
131
|
end
|
|
131
132
|
|
|
@@ -149,17 +150,15 @@ module Metanorma
|
|
|
149
150
|
|
|
150
151
|
def refitem_render_formattedref(bibitem, title)
|
|
151
152
|
(title.nil? || title.empty?) and title = @i18n.no_information_available
|
|
152
|
-
bibitem
|
|
153
|
-
|
|
154
|
-
end
|
|
153
|
+
add_noko_elem(bibitem, "formattedref", ref_normalise_no_format(title),
|
|
154
|
+
format: "application/x-isodoc+xml")
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# TODO: alternative where only title is available
|
|
158
158
|
def refitemcode(item, node)
|
|
159
159
|
m = NON_ISO_REF.match(item) and return refitem1code(item, m).compact
|
|
160
160
|
m = NON_ISO_REF1.match(item) and return refitem1code(item, m).compact
|
|
161
|
-
@log.add("
|
|
162
|
-
severity: 1)
|
|
161
|
+
@log.add("STANDOC_43", node, params: [item])
|
|
163
162
|
{}
|
|
164
163
|
end
|
|
165
164
|
|
|
@@ -42,10 +42,9 @@ module Metanorma
|
|
|
42
42
|
ref, i, doc = results.pop
|
|
43
43
|
m[i.to_i] = { ref: }
|
|
44
44
|
if doc.is_a?(RelatonBib::RequestError)
|
|
45
|
-
@log.add("
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
else m[i.to_i][:doc] = doc end
|
|
45
|
+
@log.add("STANDOC_40", nil, params: [ref[:code]])
|
|
46
|
+
else m[i.to_i][:doc] = doc
|
|
47
|
+
end
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
|
|
@@ -136,8 +135,7 @@ module Metanorma
|
|
|
136
135
|
xml.parent.add_child(smart_render_xml(hit, code, opts))
|
|
137
136
|
xml
|
|
138
137
|
rescue RelatonBib::RequestError
|
|
139
|
-
@log.add("
|
|
140
|
-
"no access to online site", severity: 1)
|
|
138
|
+
@log.add("STANDOC_40", nil, params: [code])
|
|
141
139
|
nil
|
|
142
140
|
end
|
|
143
141
|
|
|
@@ -47,8 +47,7 @@ module Metanorma
|
|
|
47
47
|
bibitem_parse(attrs, xml, node)
|
|
48
48
|
else
|
|
49
49
|
node.attr("style") == "bibliography" or
|
|
50
|
-
@log.add("
|
|
51
|
-
"Section not marked up as [bibliography]!")
|
|
50
|
+
@log.add("STANDOC_16", node)
|
|
52
51
|
nil
|
|
53
52
|
end
|
|
54
53
|
end
|
|
@@ -63,8 +62,7 @@ module Metanorma
|
|
|
63
62
|
def emend_biblio_id(xml, code)
|
|
64
63
|
unless xml.at("/bibitem/docidentifier[not(@type = 'DOI')][text()]") ||
|
|
65
64
|
/^doi:/.match?(code)
|
|
66
|
-
@log.add("
|
|
67
|
-
"ERROR: No document identifier retrieved for #{code}")
|
|
65
|
+
@log.add("STANDOC_17", nil, params: [code])
|
|
68
66
|
xml.root << "<docidentifier>#{code}</docidentifier>"
|
|
69
67
|
end
|
|
70
68
|
end
|
|
@@ -74,8 +72,7 @@ module Metanorma
|
|
|
74
72
|
def emend_biblio_title(xml, code, title)
|
|
75
73
|
fmt = /<span class=|<fn/.match?(title)
|
|
76
74
|
unless xml.at("/bibitem/title[text()]")
|
|
77
|
-
@log.add("
|
|
78
|
-
"ERROR: No title retrieved for #{code}")
|
|
75
|
+
@log.add("STANDOC_18", nil, params: [code])
|
|
79
76
|
!fmt and
|
|
80
77
|
xml.root << "<title>#{title || '(MISSING TITLE)'}</title>"
|
|
81
78
|
end
|
|
@@ -49,16 +49,12 @@ module Metanorma
|
|
|
49
49
|
else @bibdb&.docid_type(code) || [nil, code]
|
|
50
50
|
end
|
|
51
51
|
code1.sub!(/^nofetch\((.+)\)$/, "\\1")
|
|
52
|
-
bib
|
|
53
|
-
d << code1
|
|
54
|
-
end
|
|
52
|
+
add_noko_elem(bib, "docidentifier", code1, type: type)
|
|
55
53
|
end
|
|
56
54
|
|
|
57
55
|
def docnumber(bib, code)
|
|
58
56
|
code or return
|
|
59
|
-
bib
|
|
60
|
-
d << @c.decode(code).sub(/^[^\d]*/, "")
|
|
61
|
-
end
|
|
57
|
+
add_noko_elem(bib, "docnumber", @c.decode(code).sub(/^[^\d]*/, ""))
|
|
62
58
|
end
|
|
63
59
|
|
|
64
60
|
def mn_code(code)
|
|
@@ -80,7 +76,8 @@ module Metanorma
|
|
|
80
76
|
if type == :attachment then "(#{ret[type]})"
|
|
81
77
|
else ret[type].sub(%r{^[^/]+/}, "")
|
|
82
78
|
end
|
|
83
|
-
else ret[:id]
|
|
79
|
+
else ret[:id]
|
|
80
|
+
end
|
|
84
81
|
ret.merge!(id: id, type: type.to_s, key: ret[type], nofetch: true)
|
|
85
82
|
end
|
|
86
83
|
ret
|
|
@@ -201,12 +198,6 @@ module Metanorma
|
|
|
201
198
|
suppress_identifier: code[:dropid] || nil }
|
|
202
199
|
end
|
|
203
200
|
|
|
204
|
-
MALFORMED_REF = <<~REF.freeze
|
|
205
|
-
no anchor on reference, markup may be malformed: see
|
|
206
|
-
https://www.metanorma.org/author/topics/sections/bibliography/ ,
|
|
207
|
-
https://www.metanorma.org/author/iso/topics/markup/#bibliographies
|
|
208
|
-
REF
|
|
209
|
-
|
|
210
201
|
def ref_normalise(ref)
|
|
211
202
|
ref.gsub("&amp;", "&").gsub(%r{^<em>(.*)</em>}, "\\1")
|
|
212
203
|
end
|
|
@@ -87,9 +87,7 @@ module Metanorma
|
|
|
87
87
|
|
|
88
88
|
def section_title(xml, title)
|
|
89
89
|
title.nil? and return
|
|
90
|
-
xml
|
|
91
|
-
t << title
|
|
92
|
-
end
|
|
90
|
+
add_noko_elem(xml, "title", title, id_attr(nil))
|
|
93
91
|
end
|
|
94
92
|
|
|
95
93
|
def preamble(node)
|
|
@@ -102,9 +100,7 @@ module Metanorma
|
|
|
102
100
|
end
|
|
103
101
|
|
|
104
102
|
def metanorma_extension_parse(_attrs, xml, node)
|
|
105
|
-
xml
|
|
106
|
-
xml_section << node.content
|
|
107
|
-
end
|
|
103
|
+
add_noko_elem(xml, "metanorma-extension-clause", node.content)
|
|
108
104
|
end
|
|
109
105
|
|
|
110
106
|
def indexsect_parse(attrs, xml, node)
|
|
@@ -115,9 +111,7 @@ module Metanorma
|
|
|
115
111
|
end
|
|
116
112
|
|
|
117
113
|
def abstract_parse(attrs, xml, node)
|
|
118
|
-
xml
|
|
119
|
-
xml_section << node.content
|
|
120
|
-
end
|
|
114
|
+
add_noko_elem(xml, "abstract", node.content, **attr_code(attrs))
|
|
121
115
|
end
|
|
122
116
|
|
|
123
117
|
def scope_parse(attrs, xml, node)
|
|
@@ -36,7 +36,9 @@ module Metanorma
|
|
|
36
36
|
def convert
|
|
37
37
|
ret = spans_to_bibitem(@spans)
|
|
38
38
|
@out = Nokogiri::XML("<bibitem>#{ret}</bibitem>").root
|
|
39
|
-
|
|
39
|
+
%i(type language script locale).each do |k|
|
|
40
|
+
@spans[k] and @out[k.to_s] = @spans[k]
|
|
41
|
+
end
|
|
40
42
|
self
|
|
41
43
|
end
|
|
42
44
|
|
|
@@ -46,6 +48,7 @@ module Metanorma
|
|
|
46
48
|
ret += spans_to_bibitem_docid(spans)
|
|
47
49
|
ret += spans_to_contribs(spans)
|
|
48
50
|
ret += spans_to_bibitem_edn(spans)
|
|
51
|
+
ret += spans_to_bibitem_i18n(spans)
|
|
49
52
|
spans[:abstract] and ret += "<abstract>#{spans[:abstract]}</abstract>"
|
|
50
53
|
ret += spans_to_series(spans)
|
|
51
54
|
spans[:pubplace] and ret += "<place>#{spans[:pubplace]}</place>"
|
|
@@ -63,6 +66,14 @@ module Metanorma
|
|
|
63
66
|
ret
|
|
64
67
|
end
|
|
65
68
|
|
|
69
|
+
def spans_to_bibitem_i18n(spans)
|
|
70
|
+
ret = ""
|
|
71
|
+
spans[:language] and ret += "<language>#{spans[:language]}</language>"
|
|
72
|
+
spans[:script] and ret += "<script>#{spans[:script]}</script>"
|
|
73
|
+
spans[:locale] and ret += "<locale>#{spans[:locale]}</locale>"
|
|
74
|
+
ret
|
|
75
|
+
end
|
|
76
|
+
|
|
66
77
|
def spans_to_series(spans)
|
|
67
78
|
spans[:series] or return ""
|
|
68
79
|
"<series><title>#{spans[:series]}</title></series>"
|
|
@@ -37,7 +37,7 @@ module Metanorma
|
|
|
37
37
|
def spans_preprocess(spans)
|
|
38
38
|
ret = empty_span_hash
|
|
39
39
|
spans.each { |s| span_preprocess1(s, ret) }
|
|
40
|
-
host_rearrange(ret)
|
|
40
|
+
spans_defaults(host_rearrange(ret))
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
def span_preprocess1(span, ret)
|
|
@@ -52,7 +52,7 @@ module Metanorma
|
|
|
52
52
|
ret[:extent][span[:key].to_sym] ||= []
|
|
53
53
|
ret[:extent][span[:key].to_sym] << span[:val]
|
|
54
54
|
when "pubplace", "title", "type", "series", "edition", "version",
|
|
55
|
-
"abstract"
|
|
55
|
+
"abstract", "language", "script", "locale"
|
|
56
56
|
ret[span[:key].to_sym] = span[:val]
|
|
57
57
|
when "image"
|
|
58
58
|
ret[span[:key].to_sym] << { type: span[:type], val: span[:val] }
|
|
@@ -92,17 +92,21 @@ module Metanorma
|
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
+
def spans_defaults(spans)
|
|
96
|
+
spans[:language] && !spans[:script] and
|
|
97
|
+
spans[:script] = ::Metanorma::Utils.default_script(spans[:language])
|
|
98
|
+
spans
|
|
99
|
+
end
|
|
100
|
+
|
|
95
101
|
def host_rearrange(ret)
|
|
96
102
|
ret[:in][:title] or return ret
|
|
97
|
-
ret[:in].merge!(empty_span_hash, { type: "misc" })
|
|
98
|
-
old
|
|
99
|
-
end
|
|
103
|
+
ret[:in].merge!(empty_span_hash, { type: "misc" }) { |_, o, _| o }
|
|
100
104
|
%i(series).each do |k|
|
|
101
105
|
ret[:in][k] = ret[k]
|
|
102
106
|
ret.delete(k)
|
|
103
107
|
end
|
|
104
|
-
/^in/.match?(ret[:type]) and
|
|
105
|
-
|
|
108
|
+
/^in/.match?(ret[:type]) and
|
|
109
|
+
ret[:in][:type] = ret[:type].sub(/^in/, "")
|
|
106
110
|
ret
|
|
107
111
|
end
|
|
108
112
|
|
|
@@ -110,33 +110,22 @@ module Metanorma
|
|
|
110
110
|
|
|
111
111
|
def remove_missing_ref(node, target)
|
|
112
112
|
if node.at("./parent::concept[@type = 'symbol']")
|
|
113
|
-
log.add("
|
|
114
|
-
remove_missing_ref_msg(node, target, :symbol), severity: 1)
|
|
113
|
+
log.add("STANDOC_26", node, params: [target, target])
|
|
115
114
|
remove_missing_ref_term(node, target, "symbol")
|
|
116
115
|
else
|
|
117
|
-
log.add("
|
|
118
|
-
|
|
116
|
+
log.add("STANDOC_27", node,
|
|
117
|
+
params: [target, target, remove_missing_ref_msg1(node, target)])
|
|
119
118
|
remove_missing_ref_term(node, target, "term")
|
|
120
119
|
end
|
|
121
120
|
end
|
|
122
121
|
|
|
123
|
-
def
|
|
124
|
-
type == :symbol and return <<~LOG
|
|
125
|
-
Error: Symbol reference in `symbol[#{target}]` missing: "#{target}" is not defined in document
|
|
126
|
-
LOG
|
|
127
|
-
ret = <<~LOG
|
|
128
|
-
Error: Term reference to `#{target}` missing: "#{target}" is not defined in document
|
|
129
|
-
LOG
|
|
130
|
-
remove_missing_ref_msg1(node, target, ret)
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def remove_missing_ref_msg1(_node, target, ret)
|
|
122
|
+
def remove_missing_ref_msg1(_node, target)
|
|
134
123
|
target2 = "_#{target.downcase.tr('-', '_')}"
|
|
135
124
|
if @terms_tags[target] || @terms_tags[target2]
|
|
136
|
-
|
|
137
|
-
|
|
125
|
+
". Did you mean to point to a subterm?"
|
|
126
|
+
else
|
|
127
|
+
""
|
|
138
128
|
end
|
|
139
|
-
ret
|
|
140
129
|
end
|
|
141
130
|
|
|
142
131
|
def remove_missing_ref_term(node, target, type)
|
|
@@ -109,7 +109,7 @@ module Metanorma
|
|
|
109
109
|
def term_designation(xml, _node, tag, text)
|
|
110
110
|
xml.send tag do |p|
|
|
111
111
|
p.expression do |e|
|
|
112
|
-
e
|
|
112
|
+
add_noko_elem(e, "name", text)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
115
|
end
|
|
@@ -142,9 +142,7 @@ module Metanorma
|
|
|
142
142
|
|
|
143
143
|
def extract_termsource_refs(text, node)
|
|
144
144
|
matched = TERM_REFERENCE_RE.match text
|
|
145
|
-
matched.nil? and @log.add("
|
|
146
|
-
"term reference not in expected format:" \
|
|
147
|
-
"#{text}", severity: 1)
|
|
145
|
+
matched.nil? and @log.add("STANDOC_13", node, params: [text])
|
|
148
146
|
matched
|
|
149
147
|
end
|
|
150
148
|
|
|
@@ -5,6 +5,22 @@ require "json"
|
|
|
5
5
|
require "pathname"
|
|
6
6
|
require "uuidtools"
|
|
7
7
|
|
|
8
|
+
module Nokogiri
|
|
9
|
+
module XML
|
|
10
|
+
class Builder
|
|
11
|
+
class NodeBuilder
|
|
12
|
+
def add_noko_elem(name, val, attrs = {})
|
|
13
|
+
val and !val.empty? or return
|
|
14
|
+
# require "debug"; binding.b
|
|
15
|
+
send name, **Metanorma::Utils::attr_code(attrs) do |n|
|
|
16
|
+
n << val
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
8
24
|
module Metanorma
|
|
9
25
|
module Standoc
|
|
10
26
|
module Utils
|
|
@@ -44,9 +60,10 @@ module Metanorma
|
|
|
44
60
|
end
|
|
45
61
|
|
|
46
62
|
def csv_split(text, delim = ";", encode: true)
|
|
63
|
+
text ||= ""
|
|
47
64
|
ret = Metanorma::Utils::csv_split(@c.decode(text), delim)
|
|
48
65
|
encode and
|
|
49
|
-
ret.map! { |x| @c.encode(x, :basic, :hexadecimal) }
|
|
66
|
+
ret.map! { |x| @c.encode(x.strip, :basic, :hexadecimal) }
|
|
50
67
|
ret
|
|
51
68
|
end
|
|
52
69
|
|
|
@@ -155,7 +172,8 @@ module Metanorma
|
|
|
155
172
|
|
|
156
173
|
#{text}
|
|
157
174
|
ADOC
|
|
158
|
-
c = isolated_asciidoctor_convert(doc, backend: flavour,
|
|
175
|
+
c = isolated_asciidoctor_convert(doc, backend: flavour,
|
|
176
|
+
header_footer: true)
|
|
159
177
|
ret = Nokogiri::XML(c).at("//xmlns:sections")
|
|
160
178
|
separate_numbering_footnotes(ret)
|
|
161
179
|
end
|
|
@@ -192,6 +210,13 @@ module Metanorma
|
|
|
192
210
|
@refids.include? ref
|
|
193
211
|
end
|
|
194
212
|
|
|
213
|
+
def add_noko_elem(node, name, val, attrs = {})
|
|
214
|
+
val and !val.empty? or return
|
|
215
|
+
node.send name, **attr_code(attrs) do |n|
|
|
216
|
+
n << val
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
195
220
|
module_function :adoc2xml
|
|
196
221
|
|
|
197
222
|
class EmptyAttr
|