metanorma-standoc 2.4.1 → 2.4.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/Gemfile +1 -0
- data/lib/metanorma/standoc/base.rb +10 -5
- data/lib/metanorma/standoc/cleanup.rb +2 -1
- data/lib/metanorma/standoc/cleanup_block.rb +8 -2
- data/lib/metanorma/standoc/cleanup_footnotes.rb +23 -7
- data/lib/metanorma/standoc/cleanup_symbols.rb +2 -2
- data/lib/metanorma/standoc/cleanup_table.rb +15 -1
- data/lib/metanorma/standoc/cleanup_terms.rb +2 -2
- data/lib/metanorma/standoc/cleanup_terms_designations.rb +1 -21
- data/lib/metanorma/standoc/converter.rb +1 -1
- data/lib/metanorma/standoc/isodoc.rng +41 -14
- data/lib/metanorma/standoc/ref.rb +6 -5
- data/lib/metanorma/standoc/validate.rb +1 -27
- data/lib/metanorma/standoc/validate_section.rb +10 -4
- data/lib/metanorma/standoc/validate_xref.rb +32 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +3 -3
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d0ade5d859084779fe2f7357438926e03e0359adbf528d4db67a1851200f7e45
|
|
4
|
+
data.tar.gz: d17ee40a8d465764b0d7577a0ab69db5d96ab1c4e5c923b77059326d2e52e45c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 794db303464ba57e25b5ccb240b794524842fe99a42cf136f7f0ff3d0e77f82eb017676b3a0b9ef491b655ffe42b50d9332d880c4a10c9ca7a705252e62c5199
|
|
7
|
+
data.tar.gz: 6f9f27b816283a7cf27fc3b441cfd9d04a72c7a26da7d66264f3984e391e4ab3f3be384e167e1a813d8bfabcc070d98f162908a5f1a9dd5670dca3614e002873
|
data/Gemfile
CHANGED
|
@@ -168,9 +168,14 @@ module Metanorma
|
|
|
168
168
|
Metanorma.versioned(Metanorma, flavour)[-1]::VERSION
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
def
|
|
172
|
-
|
|
171
|
+
def schema_version
|
|
172
|
+
f = File.read(File.join(File.dirname(__FILE__), "isodoc.rng"))
|
|
173
|
+
m = / VERSION (v\S+)/.match(f)
|
|
174
|
+
m[1]
|
|
175
|
+
end
|
|
173
176
|
|
|
177
|
+
def clean_exit
|
|
178
|
+
@novalid or @log.write("#{@output_dir}#{@filename}.err")
|
|
174
179
|
@files_to_delete.each { |f| FileUtils.rm f }
|
|
175
180
|
end
|
|
176
181
|
|
|
@@ -185,7 +190,8 @@ module Metanorma
|
|
|
185
190
|
|
|
186
191
|
def makexml1(node)
|
|
187
192
|
result = ["<?xml version='1.0' encoding='UTF-8'?>",
|
|
188
|
-
"<#{xml_root_tag} type='semantic' version='#{version}'
|
|
193
|
+
"<#{xml_root_tag} type='semantic' version='#{version}' " \
|
|
194
|
+
"schema-version='#{schema_version}'>"]
|
|
189
195
|
result << noko { |ixml| front node, ixml }
|
|
190
196
|
result << noko { |ixml| middle node, ixml }
|
|
191
197
|
result << "</#{xml_root_tag}>"
|
|
@@ -225,8 +231,7 @@ module Metanorma
|
|
|
225
231
|
def metadata_attrs(node)
|
|
226
232
|
node.attributes.each_with_object([]) do |(k, v), ret|
|
|
227
233
|
%w(presentation semantic).each do |t|
|
|
228
|
-
|
|
229
|
-
|
|
234
|
+
/^#{t}-metadata-/.match?(k) or next
|
|
230
235
|
k = k.sub(/^#{t}-metadata-/, "")
|
|
231
236
|
csv_split(v, ",")&.each do |c|
|
|
232
237
|
ret << "<#{t}-metadata><#{k}>#{c}</#{k}></#{t}-metadata>"
|
|
@@ -31,11 +31,12 @@ module Metanorma
|
|
|
31
31
|
obligations_cleanup(xmldoc)
|
|
32
32
|
para_index_cleanup(xmldoc)
|
|
33
33
|
block_index_cleanup(xmldoc)
|
|
34
|
-
table_cleanup(xmldoc)
|
|
34
|
+
table_cleanup(xmldoc) # feeds: blocksource_cleanup
|
|
35
35
|
formula_cleanup(xmldoc)
|
|
36
36
|
form_cleanup(xmldoc)
|
|
37
37
|
sourcecode_cleanup(xmldoc) # feeds: callout_cleanup
|
|
38
38
|
figure_cleanup(xmldoc)
|
|
39
|
+
blocksource_cleanup(xmldoc)
|
|
39
40
|
requirement_cleanup(xmldoc) # feeds: xref_cleanup
|
|
40
41
|
element_name_cleanup(xmldoc)
|
|
41
42
|
ref_cleanup(xmldoc) # feeds: bibitem_cleanup
|
|
@@ -79,8 +79,7 @@ module Metanorma
|
|
|
79
79
|
def single_subfigure_cleanup(xmldoc)
|
|
80
80
|
xmldoc.xpath("//figure[figure]").each do |e|
|
|
81
81
|
s = e.xpath("./figure")
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
s.size == 1 or next
|
|
84
83
|
s[0].replace(s[0].children)
|
|
85
84
|
end
|
|
86
85
|
end
|
|
@@ -228,6 +227,13 @@ module Metanorma
|
|
|
228
227
|
"Style override set for ordered list")
|
|
229
228
|
end
|
|
230
229
|
end
|
|
230
|
+
|
|
231
|
+
def blocksource_cleanup(xmldoc)
|
|
232
|
+
xmldoc.xpath("//figure//termsource | //table//termsource").each do |s|
|
|
233
|
+
s.name = "source"
|
|
234
|
+
s.delete("type")
|
|
235
|
+
end
|
|
236
|
+
end
|
|
231
237
|
end
|
|
232
238
|
end
|
|
233
239
|
end
|
|
@@ -42,11 +42,15 @@ module Metanorma
|
|
|
42
42
|
outnum = idx
|
|
43
43
|
seen[content] = outnum
|
|
44
44
|
end
|
|
45
|
-
fnote["reference"] = (outnum
|
|
45
|
+
fnote["reference"] = table_footnote_number(outnum)
|
|
46
46
|
fnote["table"] = true
|
|
47
47
|
[idx, seen]
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
def table_footnote_number(outnum)
|
|
51
|
+
(outnum - 1 + "a".ord).chr
|
|
52
|
+
end
|
|
53
|
+
|
|
50
54
|
def table_footnote_renumber(xmldoc)
|
|
51
55
|
xmldoc.xpath("//table | //figure").each do |t|
|
|
52
56
|
seen = {}
|
|
@@ -90,16 +94,28 @@ module Metanorma
|
|
|
90
94
|
end
|
|
91
95
|
|
|
92
96
|
def footnote_block_cleanup(xmldoc)
|
|
93
|
-
xmldoc.xpath("//footnoteblock").
|
|
97
|
+
ids = xmldoc.xpath("//footnoteblock").each_with_object([]) do |f, m|
|
|
94
98
|
f.name = "fn"
|
|
99
|
+
m << f.text
|
|
95
100
|
if id = xmldoc.at("//*[@id = '#{f.text}']")
|
|
96
|
-
f.children = id.
|
|
97
|
-
else
|
|
98
|
-
@log.add("Crossreferences", f,
|
|
99
|
-
"Could not resolve footnoteblock:[#{f.text}]")
|
|
100
|
-
f.children = "[ERROR]"
|
|
101
|
+
f.children = id.dup.children
|
|
102
|
+
else footnote_block_error(f)
|
|
101
103
|
end
|
|
102
104
|
end
|
|
105
|
+
footnote_block_remove(xmldoc, ids)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
def footnote_block_remove(xmldoc, ids)
|
|
109
|
+
ids.each do |id|
|
|
110
|
+
n = xmldoc.at("//*[@id = '#{id}']") and
|
|
111
|
+
n.remove
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def footnote_block_error(fnote)
|
|
116
|
+
@log.add("Crossreferences", fnote,
|
|
117
|
+
"Could not resolve footnoteblock:[#{fnote.text}]")
|
|
118
|
+
fnote.children = "[ERROR]"
|
|
103
119
|
end
|
|
104
120
|
|
|
105
121
|
def footnote_cleanup(xmldoc)
|
|
@@ -17,9 +17,9 @@ module Metanorma
|
|
|
17
17
|
def asciimath_key(sym)
|
|
18
18
|
key = sym.dup
|
|
19
19
|
key.traverse do |n|
|
|
20
|
-
if n.name == "
|
|
20
|
+
if n.name == "stem" && a = n.at(".//asciimath")
|
|
21
21
|
n.children = @c.encode(
|
|
22
|
-
@c.decode(grkletters(
|
|
22
|
+
@c.decode(grkletters(a.text)), :basic
|
|
23
23
|
)
|
|
24
24
|
end
|
|
25
25
|
end
|
|
@@ -46,16 +46,30 @@ module Metanorma
|
|
|
46
46
|
def table_cleanup(xmldoc)
|
|
47
47
|
dl1_table_cleanup(xmldoc)
|
|
48
48
|
dl2_table_cleanup(xmldoc)
|
|
49
|
+
sources_table_cleanup(xmldoc)
|
|
49
50
|
notes_table_cleanup(xmldoc)
|
|
50
51
|
header_rows_cleanup(xmldoc)
|
|
51
52
|
end
|
|
52
53
|
|
|
54
|
+
def sources_table_cleanup(xmldoc)
|
|
55
|
+
nomatches = false
|
|
56
|
+
until nomatches
|
|
57
|
+
nomatches = true
|
|
58
|
+
xmldoc.xpath("//table/following-sibling::*[1]" \
|
|
59
|
+
"[self::termsource]").each do |n|
|
|
60
|
+
n.previous_element << n.remove
|
|
61
|
+
nomatches = false
|
|
62
|
+
# will be renamed source from termsource later
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
53
67
|
# move notes into table
|
|
54
68
|
def notes_table_cleanup(xmldoc)
|
|
55
69
|
nomatches = false
|
|
56
70
|
until nomatches
|
|
57
71
|
nomatches = true
|
|
58
|
-
xmldoc.xpath("//table/following-sibling::*[1]"\
|
|
72
|
+
xmldoc.xpath("//table/following-sibling::*[1]" \
|
|
59
73
|
"[self::note[not(@keep-separate = 'true')]]").each do |n|
|
|
60
74
|
n.delete("keep-separate")
|
|
61
75
|
n.previous_element << n.remove
|
|
@@ -27,7 +27,7 @@ module Metanorma
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
TERMDEF_BLOCKS =
|
|
30
|
-
"./p | ./ol | ./dl[not(@metadata = 'true')] | ./ul | ./figure | "\
|
|
30
|
+
"./p | ./ol | ./dl[not(@metadata = 'true')] | ./ul | ./figure | " \
|
|
31
31
|
"./formula | ./table".freeze
|
|
32
32
|
|
|
33
33
|
def generate_termdefinitions(xmldoc)
|
|
@@ -47,7 +47,7 @@ module Metanorma
|
|
|
47
47
|
if d.at("./p | ./ol | ./dl | ./ul")
|
|
48
48
|
d.children = "<verbal-definition>#{d.children}</verbal-definition>"
|
|
49
49
|
else
|
|
50
|
-
d.children = "<non-verbal-representation>"\
|
|
50
|
+
d.children = "<non-verbal-representation>" \
|
|
51
51
|
"#{d.children}</non-verbal-representation>"
|
|
52
52
|
end
|
|
53
53
|
end
|
|
@@ -2,7 +2,6 @@ module Metanorma
|
|
|
2
2
|
module Standoc
|
|
3
3
|
module Cleanup
|
|
4
4
|
def termdef_stem_cleanup(xmldoc)
|
|
5
|
-
termdef_stem2admitted(xmldoc)
|
|
6
5
|
xmldoc.xpath("//term//expression/name[stem]").each do |n|
|
|
7
6
|
test = n.dup
|
|
8
7
|
test.at("./stem").remove
|
|
@@ -12,25 +11,6 @@ module Metanorma
|
|
|
12
11
|
end
|
|
13
12
|
end
|
|
14
13
|
|
|
15
|
-
def termdef_stem2admitted(xmldoc)
|
|
16
|
-
xmldoc.xpath("//term/p/stem").each do |a|
|
|
17
|
-
if initial_formula(a.parent)
|
|
18
|
-
parent = a.parent
|
|
19
|
-
parent.replace("<admitted>#{term_expr(a.to_xml)}</admitted>")
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
xmldoc.xpath("//term/formula").each do |a|
|
|
23
|
-
initial_formula(a) and
|
|
24
|
-
a.replace("<admitted>#{term_expr(a.children.to_xml)}</admitted>")
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def initial_formula(elem)
|
|
29
|
-
elem.elements.size == 1 && # para contains just stem expression
|
|
30
|
-
!elem.at("./preceding-sibling::p | ./preceding-sibling::dl | "\
|
|
31
|
-
"./preceding-sibling::ol | ./preceding-sibling::ul")
|
|
32
|
-
end
|
|
33
|
-
|
|
34
14
|
# release termdef tags from surrounding paras
|
|
35
15
|
def termdef_unnest_cleanup(xmldoc)
|
|
36
16
|
desgn = "//p/admitted | //p/deprecates | //p/preferred | //p//related"
|
|
@@ -136,7 +116,7 @@ module Metanorma
|
|
|
136
116
|
def dl_to_designation(dlist)
|
|
137
117
|
prev = dlist.previous_element
|
|
138
118
|
unless %w(preferred admitted deprecates related).include? prev&.name
|
|
139
|
-
@log.add("AsciiDoc Input", dlist, "Metadata definition list does "\
|
|
119
|
+
@log.add("AsciiDoc Input", dlist, "Metadata definition list does " \
|
|
140
120
|
"not follow a term designation")
|
|
141
121
|
return nil
|
|
142
122
|
end
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
|
18
18
|
of this.
|
|
19
19
|
-->
|
|
20
|
+
<!-- VERSION v1.2.1 -->
|
|
20
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">
|
|
21
22
|
<include href="reqt.rng"/>
|
|
22
23
|
<include href="basicdoc.rng">
|
|
@@ -382,6 +383,9 @@
|
|
|
382
383
|
<optional>
|
|
383
384
|
<ref name="dl"/>
|
|
384
385
|
</optional>
|
|
386
|
+
<optional>
|
|
387
|
+
<ref name="source"/>
|
|
388
|
+
</optional>
|
|
385
389
|
</element>
|
|
386
390
|
</define>
|
|
387
391
|
<define name="figure">
|
|
@@ -404,9 +408,6 @@
|
|
|
404
408
|
<attribute name="class"/>
|
|
405
409
|
</optional>
|
|
406
410
|
<ref name="BlockAttributes"/>
|
|
407
|
-
<optional>
|
|
408
|
-
<ref name="source"/>
|
|
409
|
-
</optional>
|
|
410
411
|
<optional>
|
|
411
412
|
<ref name="tname"/>
|
|
412
413
|
</optional>
|
|
@@ -431,6 +432,20 @@
|
|
|
431
432
|
<zeroOrMore>
|
|
432
433
|
<ref name="note"/>
|
|
433
434
|
</zeroOrMore>
|
|
435
|
+
<optional>
|
|
436
|
+
<ref name="source"/>
|
|
437
|
+
</optional>
|
|
438
|
+
</element>
|
|
439
|
+
</define>
|
|
440
|
+
<define name="source">
|
|
441
|
+
<element name="source">
|
|
442
|
+
<attribute name="status">
|
|
443
|
+
<ref name="SourceStatusType"/>
|
|
444
|
+
</attribute>
|
|
445
|
+
<ref name="origin"/>
|
|
446
|
+
<optional>
|
|
447
|
+
<ref name="modification"/>
|
|
448
|
+
</optional>
|
|
434
449
|
</element>
|
|
435
450
|
</define>
|
|
436
451
|
<define name="sourcecode">
|
|
@@ -1335,15 +1350,19 @@
|
|
|
1335
1350
|
</choice>
|
|
1336
1351
|
</element>
|
|
1337
1352
|
</define>
|
|
1353
|
+
<define name="Root-Attributes">
|
|
1354
|
+
<attribute name="version"/>
|
|
1355
|
+
<attribute name="schema-version"/>
|
|
1356
|
+
<attribute name="type">
|
|
1357
|
+
<choice>
|
|
1358
|
+
<value>semantic</value>
|
|
1359
|
+
<value>presentation</value>
|
|
1360
|
+
</choice>
|
|
1361
|
+
</attribute>
|
|
1362
|
+
</define>
|
|
1338
1363
|
<define name="standard-document">
|
|
1339
1364
|
<element name="standard-document">
|
|
1340
|
-
<
|
|
1341
|
-
<attribute name="type">
|
|
1342
|
-
<choice>
|
|
1343
|
-
<value>semantic</value>
|
|
1344
|
-
<value>presentation</value>
|
|
1345
|
-
</choice>
|
|
1346
|
-
</attribute>
|
|
1365
|
+
<ref name="Root-Attributes"/>
|
|
1347
1366
|
<ref name="bibdata"/>
|
|
1348
1367
|
<optional>
|
|
1349
1368
|
<ref name="misccontainer"/>
|
|
@@ -2099,10 +2118,7 @@
|
|
|
2099
2118
|
<define name="termsource">
|
|
2100
2119
|
<element name="termsource">
|
|
2101
2120
|
<attribute name="status">
|
|
2102
|
-
<
|
|
2103
|
-
<value>identical</value>
|
|
2104
|
-
<value>modified</value>
|
|
2105
|
-
</choice>
|
|
2121
|
+
<ref name="SourceStatusType"/>
|
|
2106
2122
|
</attribute>
|
|
2107
2123
|
<attribute name="type">
|
|
2108
2124
|
<choice>
|
|
@@ -2116,6 +2132,17 @@
|
|
|
2116
2132
|
</optional>
|
|
2117
2133
|
</element>
|
|
2118
2134
|
</define>
|
|
2135
|
+
<define name="SourceStatusType">
|
|
2136
|
+
<choice>
|
|
2137
|
+
<value>identical</value>
|
|
2138
|
+
<value>modified</value>
|
|
2139
|
+
<value>restyled</value>
|
|
2140
|
+
<value>context-added</value>
|
|
2141
|
+
<value>generalisation</value>
|
|
2142
|
+
<value>specialisation</value>
|
|
2143
|
+
<value>unspecified</value>
|
|
2144
|
+
</choice>
|
|
2145
|
+
</define>
|
|
2119
2146
|
<define name="origin">
|
|
2120
2147
|
<element name="origin">
|
|
2121
2148
|
<choice>
|
|
@@ -122,7 +122,7 @@ module Metanorma
|
|
|
122
122
|
t.formattedref format: "application/x-isodoc+xml" do |i|
|
|
123
123
|
i << ref_normalise_no_format(match[:text])
|
|
124
124
|
end
|
|
125
|
-
yr_match =
|
|
125
|
+
yr_match = refitem1yr(code[:id])
|
|
126
126
|
refitem_render1(match, code, t)
|
|
127
127
|
/^\d+$|^\(.+\)$/.match?(code[:id]) or
|
|
128
128
|
docnumber(t, code[:id].sub(/[:-](19|20)[0-9][0-9]$/, ""))
|
|
@@ -143,16 +143,17 @@ module Metanorma
|
|
|
143
143
|
((code[:id] && code[:numeric]) || code[:nofetch]) and
|
|
144
144
|
return { code: nil, match: match, analyse_code: code,
|
|
145
145
|
hidden: code[:hidden] }
|
|
146
|
-
year = refitem1yr(code[:id])
|
|
147
146
|
{ code: code[:id], analyse_code: code, localfile: code[:localfile],
|
|
148
|
-
year: year,
|
|
147
|
+
year: (m = refitem1yr(code[:id])) ? m[:year] : nil,
|
|
149
148
|
title: match[:text], match: match, hidden: code[:hidden],
|
|
150
149
|
usrlbl: match[:usrlbl], lang: (@lang || :all) }
|
|
151
150
|
end
|
|
152
151
|
|
|
153
152
|
def refitem1yr(code)
|
|
154
|
-
yr_match = /[:-](?<year>(?:19|20)[0-9][0-9])
|
|
155
|
-
|
|
153
|
+
yr_match = /[:-](?<year>(?:19|20)[0-9][0-9])$/.match(code)
|
|
154
|
+
/[:-](?:19|20)[0-9][0-9].*?[:-](?:19|20)[0-9][0-9]$/.match(code) and
|
|
155
|
+
yr_match = nil
|
|
156
|
+
yr_match
|
|
156
157
|
end
|
|
157
158
|
|
|
158
159
|
def refitemout(item, xml)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
require "metanorma/standoc/utils"
|
|
2
2
|
require_relative "./validate_section"
|
|
3
3
|
require_relative "./validate_table"
|
|
4
|
+
require_relative "./validate_xref"
|
|
4
5
|
require "nokogiri"
|
|
5
6
|
require "jing"
|
|
6
7
|
require "iev"
|
|
@@ -155,22 +156,6 @@ module Metanorma
|
|
|
155
156
|
ret
|
|
156
157
|
end
|
|
157
158
|
|
|
158
|
-
def repeat_id_validate1(elem)
|
|
159
|
-
if @doc_ids[elem["id"]]
|
|
160
|
-
@log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
|
|
161
|
-
"used at line #{@doc_ids[elem['id']]}")
|
|
162
|
-
@fatalerror << "Multiple instances of same ID: #{elem['id']}"
|
|
163
|
-
end
|
|
164
|
-
@doc_ids[elem["id"]] = elem.line
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def repeat_id_validate(doc)
|
|
168
|
-
@doc_ids = {}
|
|
169
|
-
doc.xpath("//*[@id]").each do |x|
|
|
170
|
-
repeat_id_validate1(x)
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
159
|
def schema_validate(doc, schema)
|
|
175
160
|
Tempfile.open(["tmp", ".xml"], encoding: "UTF-8") do |f|
|
|
176
161
|
schema_validate1(f, doc, schema)
|
|
@@ -214,17 +199,6 @@ module Metanorma
|
|
|
214
199
|
doc
|
|
215
200
|
end
|
|
216
201
|
|
|
217
|
-
# manually check for xref/@target, xref/@to integrity
|
|
218
|
-
def xref_validate(doc)
|
|
219
|
-
@doc_xrefs = doc.xpath("//xref/@target | //xref/@to")
|
|
220
|
-
.each_with_object({}) do |x, m|
|
|
221
|
-
m[x.text] = x
|
|
222
|
-
@doc_ids[x.text] and next
|
|
223
|
-
@log.add("Anchors", x.parent,
|
|
224
|
-
"Crossreference target #{x} is undefined")
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
|
|
228
202
|
def image_validate(doc)
|
|
229
203
|
image_exists(doc)
|
|
230
204
|
png_validate(doc)
|
|
@@ -13,10 +13,16 @@ module Metanorma
|
|
|
13
13
|
root.xpath("//sourcecode").each do |x|
|
|
14
14
|
callouts = x.elements.select { |e| e.name == "callout" }
|
|
15
15
|
annotations = x.elements.select { |e| e.name == "annotation" }
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
callouts_error(x, callouts, annotations)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def callouts_error(elem, callouts, annotations)
|
|
21
|
+
if callouts.size != annotations.size && !annotations.empty?
|
|
22
|
+
err = "mismatch of callouts (#{callouts.size}) and annotations " \
|
|
23
|
+
"(#{annotations.size})"
|
|
24
|
+
@log.add("AsciiDoc Input", elem, err)
|
|
25
|
+
@fatalerror << err
|
|
20
26
|
end
|
|
21
27
|
end
|
|
22
28
|
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Metanorma
|
|
2
|
+
module Standoc
|
|
3
|
+
module Validate
|
|
4
|
+
def repeat_id_validate1(elem)
|
|
5
|
+
if @doc_ids[elem["id"]]
|
|
6
|
+
@log.add("Anchors", elem, "Anchor #{elem['id']} has already been " \
|
|
7
|
+
"used at line #{@doc_ids[elem['id']]}")
|
|
8
|
+
@fatalerror << "Multiple instances of same ID: #{elem['id']}"
|
|
9
|
+
end
|
|
10
|
+
@doc_ids[elem["id"]] = elem.line
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def repeat_id_validate(doc)
|
|
14
|
+
@doc_ids = {}
|
|
15
|
+
doc.xpath("//*[@id]").each do |x|
|
|
16
|
+
repeat_id_validate1(x)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# manually check for xref/@target, xref/@to integrity
|
|
21
|
+
def xref_validate(doc)
|
|
22
|
+
@doc_xrefs = doc.xpath("//xref/@target | //xref/@to")
|
|
23
|
+
.each_with_object({}) do |x, m|
|
|
24
|
+
m[x.text] = x
|
|
25
|
+
@doc_ids[x.text] and next
|
|
26
|
+
@log.add("Anchors", x.parent,
|
|
27
|
+
"Crossreference target #{x} is undefined")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/metanorma-standoc.gemspec
CHANGED
|
@@ -30,8 +30,8 @@ Gem::Specification.new do |spec|
|
|
|
30
30
|
|
|
31
31
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
|
32
32
|
spec.add_dependency "iev", "~> 0.3.0"
|
|
33
|
-
spec.add_dependency "isodoc", "~> 2.5.
|
|
34
|
-
spec.add_dependency "metanorma"
|
|
33
|
+
spec.add_dependency "isodoc", "~> 2.5.4"
|
|
34
|
+
spec.add_dependency "metanorma", ">= 1.5.0"
|
|
35
35
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
|
36
36
|
spec.add_dependency "metanorma-plugin-lutaml"
|
|
37
37
|
spec.add_dependency "ruby-jing"
|
|
@@ -41,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
|
41
41
|
spec.add_dependency "plurimath"
|
|
42
42
|
spec.add_dependency "pngcheck"
|
|
43
43
|
spec.add_dependency "relaton-cli", "~> 1.15.0"
|
|
44
|
-
spec.add_dependency "relaton-iev", "~> 1.1.
|
|
44
|
+
spec.add_dependency "relaton-iev", "~> 1.1.5"
|
|
45
45
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
|
46
46
|
|
|
47
47
|
spec.add_development_dependency "debug"
|
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.4.
|
|
4
|
+
version: 2.4.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: 2023-
|
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: asciidoctor
|
|
@@ -44,28 +44,28 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: 2.5.
|
|
47
|
+
version: 2.5.4
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: 2.5.
|
|
54
|
+
version: 2.5.4
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: metanorma
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: 1.5.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:
|
|
68
|
+
version: 1.5.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: metanorma-plugin-datastruct
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,14 +184,14 @@ dependencies:
|
|
|
184
184
|
requirements:
|
|
185
185
|
- - "~>"
|
|
186
186
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 1.1.
|
|
187
|
+
version: 1.1.5
|
|
188
188
|
type: :runtime
|
|
189
189
|
prerelease: false
|
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
191
|
requirements:
|
|
192
192
|
- - "~>"
|
|
193
193
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 1.1.
|
|
194
|
+
version: 1.1.5
|
|
195
195
|
- !ruby/object:Gem::Dependency
|
|
196
196
|
name: unicode2latex
|
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -514,6 +514,7 @@ files:
|
|
|
514
514
|
- lib/metanorma/standoc/validate.rb
|
|
515
515
|
- lib/metanorma/standoc/validate_section.rb
|
|
516
516
|
- lib/metanorma/standoc/validate_table.rb
|
|
517
|
+
- lib/metanorma/standoc/validate_xref.rb
|
|
517
518
|
- lib/metanorma/standoc/version.rb
|
|
518
519
|
- lib/metanorma/standoc/views/datamodel/model_representation.adoc.erb
|
|
519
520
|
- lib/metanorma/standoc/views/datamodel/plantuml_representation.adoc.erb
|