metanorma-standoc 2.4.2 → 2.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/base.rb +10 -5
- data/lib/metanorma/standoc/cleanup_block.rb +1 -2
- data/lib/metanorma/standoc/cleanup_footnotes.rb +5 -1
- data/lib/metanorma/standoc/converter.rb +1 -1
- data/lib/metanorma/standoc/isodoc.rng +12 -7
- data/lib/metanorma/standoc/ref.rb +6 -5
- data/lib/metanorma/standoc/validate.rb +1 -27
- data/lib/metanorma/standoc/validate_xref.rb +32 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- metadata +5 -4
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
|
@@ -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>"
|
@@ -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 = {}
|
@@ -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">
|
@@ -1349,15 +1350,19 @@
|
|
1349
1350
|
</choice>
|
1350
1351
|
</element>
|
1351
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>
|
1352
1363
|
<define name="standard-document">
|
1353
1364
|
<element name="standard-document">
|
1354
|
-
<
|
1355
|
-
<attribute name="type">
|
1356
|
-
<choice>
|
1357
|
-
<value>semantic</value>
|
1358
|
-
<value>presentation</value>
|
1359
|
-
</choice>
|
1360
|
-
</attribute>
|
1365
|
+
<ref name="Root-Attributes"/>
|
1361
1366
|
<ref name="bibdata"/>
|
1362
1367
|
<optional>
|
1363
1368
|
<ref name="misccontainer"/>
|
@@ -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)
|
@@ -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,7 +30,7 @@ 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.
|
33
|
+
spec.add_dependency "isodoc", "~> 2.5.4"
|
34
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"
|
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-04-
|
11
|
+
date: 2023-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -44,14 +44,14 @@ 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
|
@@ -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
|