metanorma-standoc 2.0.4 → 2.0.5
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/base.rb +21 -10
- data/lib/metanorma/standoc/blocks.rb +1 -1
- data/lib/metanorma/standoc/cleanup_amend.rb +33 -30
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +26 -2
- data/lib/metanorma/standoc/cleanup_ref_dl.rb +7 -2
- data/lib/metanorma/standoc/cleanup_text.rb +39 -17
- data/lib/metanorma/standoc/converter.rb +1 -1
- data/lib/metanorma/standoc/macros.rb +1 -1
- data/lib/metanorma/standoc/macros_embed.rb +34 -13
- data/lib/metanorma/standoc/macros_note.rb +4 -3
- data/lib/metanorma/standoc/processor.rb +6 -1
- data/lib/metanorma/standoc/ref.rb +9 -9
- data/lib/metanorma/standoc/ref_utility.rb +6 -5
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +8 -5
- data/lib/metanorma/standoc/validate.rb +79 -10
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/assets/a2.adoc +4 -2
- data/spec/assets/a3.adoc +2 -2
- data/spec/assets/a3a.adoc +7 -0
- data/spec/metanorma/cleanup_spec.rb +21 -10
- data/spec/metanorma/cleanup_terms_spec.rb +15 -3
- data/spec/metanorma/macros_spec.rb +68 -2
- data/spec/metanorma/validate_spec.rb +108 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 219579e1dcc116cb03bfddaa5d11819180d7e5b8b306f499335a39a61c2e8075
|
4
|
+
data.tar.gz: 7d8c958d3ae1e834d5e8a93c8ee3c8ebb4040e4dcee899f1bc66c87e538cdad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4925a6bbee7f29186d5a98cd90a51c647b4443b383f5b09e714554c1bc12da5f88c7c7143236077d96ea3685f2885c4057f245c687a5404d9f6c77489ea8063
|
7
|
+
data.tar.gz: 3644084092782115188b9240f0e8dc68e4ef4b2bb663e5e4270214ab861018ec3a3c4bfd082fbb49f9134af62e714acb309fa774d7ebeaac85a4b20444ef5ef9
|
@@ -26,29 +26,40 @@ module Metanorma
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def init(node)
|
29
|
+
init_vars
|
30
|
+
init_misc(node)
|
31
|
+
init_processing(node)
|
32
|
+
init_toc(node)
|
33
|
+
init_output(node)
|
34
|
+
init_i18n(node)
|
35
|
+
init_biblio(node)
|
36
|
+
@metadata_attrs = metadata_attrs(node)
|
37
|
+
end
|
38
|
+
|
39
|
+
def init_vars
|
29
40
|
@fn_number ||= 0
|
30
|
-
@draft = false
|
31
41
|
@refids = Set.new
|
32
42
|
@anchors = {}
|
33
43
|
@internal_eref_namespaces = []
|
34
44
|
@seen_headers = []
|
45
|
+
@embed_hdr = []
|
46
|
+
end
|
47
|
+
|
48
|
+
def init_misc(node)
|
35
49
|
@draft = node.attributes.has_key?("draft")
|
50
|
+
@index_terms = node.attr("index-terms")
|
51
|
+
@boilerplateauthority = node.attr("boilerplate-authority")
|
52
|
+
@embed_hdr = node.attr("embed_hdr")
|
53
|
+
end
|
54
|
+
|
55
|
+
def init_processing(node)
|
36
56
|
@novalid = node.attr("novalid")
|
37
57
|
@smartquotes = node.attr("smartquotes") != "false"
|
38
58
|
@keepasciimath = node.attr("mn-keep-asciimath") &&
|
39
59
|
node.attr("mn-keep-asciimath") != "false"
|
40
|
-
@index_terms = node.attr("index-terms")
|
41
60
|
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
42
61
|
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
43
62
|
@datauriimage = node.attr("data-uri-image") != "false"
|
44
|
-
@boilerplateauthority = node.attr("boilerplate-authority")
|
45
|
-
@sourcecode_markup_start = node.attr("sourcecode-markup-start") || "{{{"
|
46
|
-
@sourcecode_markup_end = node.attr("sourcecode-markup-end") || "}}}"
|
47
|
-
init_toc(node)
|
48
|
-
init_output(node)
|
49
|
-
init_i18n(node)
|
50
|
-
init_biblio(node)
|
51
|
-
@metadata_attrs = metadata_attrs(node)
|
52
63
|
end
|
53
64
|
|
54
65
|
def init_toc(node)
|
@@ -188,7 +188,7 @@ module Metanorma
|
|
188
188
|
|
189
189
|
def quote_attribution(node, out)
|
190
190
|
if node.attr("citetitle")
|
191
|
-
m = /^(?<cite>[^,]+)(
|
191
|
+
m = /^(?<cite>[^,]+)(?:,(?<text>.*$))?$/m.match node.attr("citetitle")
|
192
192
|
out.source **attr_code(target: m[:cite], type: "inline") do |s|
|
193
193
|
s << m[:text]
|
194
194
|
end
|
@@ -1,53 +1,56 @@
|
|
1
1
|
module Metanorma
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
|
-
def change_clauses(
|
5
|
-
|
6
|
-
|
4
|
+
def change_clauses(docxml)
|
5
|
+
docxml.xpath("//clause[@change]").each do |c|
|
6
|
+
create_amend(c)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
def create_amend(
|
11
|
-
a =
|
12
|
-
|
10
|
+
def create_amend(clause)
|
11
|
+
a = clause.add_child("<amend id='_#{UUIDTools::UUID.random_create}'/>")
|
12
|
+
.first
|
13
|
+
clause.elements.each do |e|
|
13
14
|
e.parent = a unless %w(amend title).include? e.name
|
14
15
|
end
|
15
|
-
create_amend1(
|
16
|
+
create_amend1(clause, a)
|
16
17
|
end
|
17
18
|
|
18
|
-
def create_amend1(
|
19
|
-
create_amend2(
|
20
|
-
d =
|
19
|
+
def create_amend1(clause, amend)
|
20
|
+
create_amend2(clause, amend)
|
21
|
+
d = amend.at("./description")
|
21
22
|
d.xpath(".//autonumber").each { |e| d.previous = e }
|
22
|
-
d.xpath(".//p[normalize-space(.)='']").each
|
23
|
-
move_attrs_to_amend(
|
24
|
-
|
23
|
+
d.xpath(".//p[normalize-space(.)='']").each(&:remove)
|
24
|
+
move_attrs_to_amend(clause, amend)
|
25
|
+
amend
|
25
26
|
end
|
26
27
|
|
27
|
-
def create_amend2(
|
28
|
-
q =
|
28
|
+
def create_amend2(_clause, amend)
|
29
|
+
q = amend.at("./quote") and q.name = "newcontent"
|
29
30
|
if q.nil?
|
30
|
-
|
31
|
-
|
32
|
-
pre = q&.xpath("./preceding-sibling::*")&.remove
|
33
|
-
post = q&.xpath("./following-sibling::*")&.remove
|
34
|
-
pre.empty? or a << "<description>#{pre.to_xml}</description>"
|
35
|
-
a << q.remove
|
36
|
-
post.empty? or a << "<description>#{post.to_xml}</description>"
|
31
|
+
amend.children = "<description>#{amend.children.to_xml}</description>"
|
32
|
+
return
|
37
33
|
end
|
34
|
+
pre = q&.xpath("./preceding-sibling::*")&.remove
|
35
|
+
post = q&.xpath("./following-sibling::*")&.remove
|
36
|
+
pre.empty? or amend << "<description>#{pre.to_xml}</description>"
|
37
|
+
amend << q.remove
|
38
|
+
post.empty? or amend << "<description>#{post.to_xml}</description>"
|
38
39
|
end
|
39
40
|
|
40
|
-
def move_attrs_to_amend(
|
41
|
+
def move_attrs_to_amend(clause, amend)
|
41
42
|
%w(change path path_end title).each do |e|
|
42
|
-
next unless
|
43
|
-
|
44
|
-
|
43
|
+
next unless clause[e]
|
44
|
+
|
45
|
+
amend[e] = clause[e]
|
46
|
+
clause.delete(e)
|
45
47
|
end
|
46
|
-
return unless
|
47
|
-
|
48
|
-
|
48
|
+
return unless amend["locality"]
|
49
|
+
|
50
|
+
loc = amend.children.add_previous_sibling("<location/>")
|
51
|
+
extract_localities1(loc, amend["locality"])
|
49
52
|
loc1 = loc.at("./localityStack") and loc.replace(loc1.elements)
|
50
|
-
|
53
|
+
amend.delete("locality")
|
51
54
|
end
|
52
55
|
end
|
53
56
|
end
|
@@ -133,6 +133,7 @@ module Metanorma
|
|
133
133
|
def bibdata_cleanup(xmldoc)
|
134
134
|
bibdata_anchor_cleanup(xmldoc)
|
135
135
|
bibdata_docidentifier_cleanup(xmldoc)
|
136
|
+
bibdata_embed_hdr_cleanup(xmldoc)
|
136
137
|
biblio_indirect_erefs(xmldoc, @internal_eref_namespaces&.uniq)
|
137
138
|
end
|
138
139
|
|
@@ -190,8 +191,8 @@ module Metanorma
|
|
190
191
|
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
191
192
|
refs.each_with_object([]) do |r, m|
|
192
193
|
id = r.sub(/^#{prefix}_/, "")
|
193
|
-
|
194
|
-
|
194
|
+
n = xmldoc.at("//*[@id = '#{id}']")
|
195
|
+
if n&.at("./ancestor-or-self::*[@type = '#{prefix}']")
|
195
196
|
xmldoc.xpath("//eref[@bibitemid = '#{r}']").each do |e|
|
196
197
|
indirect_eref_to_xref(e, id)
|
197
198
|
end
|
@@ -208,6 +209,29 @@ module Metanorma
|
|
208
209
|
insert_indirect_biblio(xmldoc, refs, prefix)
|
209
210
|
end
|
210
211
|
end
|
212
|
+
|
213
|
+
def bibdata_embed_hdr_cleanup(xmldoc)
|
214
|
+
return if @embed_hdr.nil? || @embed_hdr.empty?
|
215
|
+
|
216
|
+
embed_recurse(xmldoc.at("//bibdata"), @embed_hdr.first)
|
217
|
+
end
|
218
|
+
|
219
|
+
def hdr2bibitem(hdr)
|
220
|
+
xml = Asciidoctor
|
221
|
+
.convert(hdr[:text], backend: Processor.new.asciidoctor_backend,
|
222
|
+
header_footer: true)
|
223
|
+
b = Nokogiri::XML(xml).at("//xmlns:bibdata")
|
224
|
+
b.name = "bibitem"
|
225
|
+
b.delete("type")
|
226
|
+
embed_recurse(b, hdr)
|
227
|
+
b.to_xml
|
228
|
+
end
|
229
|
+
|
230
|
+
def embed_recurse(bibitem, node)
|
231
|
+
node[:child].map { |x| hdr2bibitem(x) }.each do |x|
|
232
|
+
bibitem << "<relation type='derivedFrom'>#{x}</relation>"
|
233
|
+
end
|
234
|
+
end
|
211
235
|
end
|
212
236
|
end
|
213
237
|
end
|
@@ -15,16 +15,21 @@ module Metanorma
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
# do not accept implicit id
|
18
19
|
def validate_ref_dl(bib, clause)
|
19
20
|
id = bib["id"]
|
20
|
-
# do not accept implicit id
|
21
21
|
id ||= clause["id"] unless /^_/.match?(clause["id"])
|
22
22
|
unless id
|
23
23
|
@log.add("Anchors", clause,
|
24
|
-
"The following reference is missing an anchor:\n
|
24
|
+
"The following reference is missing an anchor:\n"\
|
25
|
+
"#{clause.to_xml}")
|
25
26
|
return
|
26
27
|
end
|
27
28
|
@refids << id
|
29
|
+
validate_ref_dl1(bib, id, clause)
|
30
|
+
end
|
31
|
+
|
32
|
+
def validate_ref_dl1(bib, id, clause)
|
28
33
|
bib["title"] or
|
29
34
|
@log.add("Bibliography", clause, "Reference #{id} is missing a title")
|
30
35
|
bib["docid"] or
|
@@ -9,12 +9,6 @@ module Metanorma
|
|
9
9
|
</passthrough>}mx) { HTMLEntities.new.decode($1) }
|
10
10
|
end
|
11
11
|
|
12
|
-
IGNORE_DUMBQUOTES =
|
13
|
-
"//pre | //pre//* | //tt | //tt//* | "\
|
14
|
-
"//sourcecode | //sourcecode//* | //bibdata//* | //stem | "\
|
15
|
-
"//stem//* | //figure[@class = 'pseudocode'] | "\
|
16
|
-
"//figure[@class = 'pseudocode']//*".freeze
|
17
|
-
|
18
12
|
def smartquotes_cleanup(xmldoc)
|
19
13
|
xmldoc.xpath("//date").each { |d| Metanorma::Utils::endash_date(d) }
|
20
14
|
if @smartquotes then smartquotes_cleanup1(xmldoc)
|
@@ -31,14 +25,21 @@ module Metanorma
|
|
31
25
|
def uninterrupt_quotes_around_xml(xmldoc)
|
32
26
|
xmldoc.traverse do |n|
|
33
27
|
next unless n.text? && n&.previous&.element?
|
34
|
-
next
|
35
|
-
next unless n.previous.ancestors("pre, tt, sourcecode, stem, figure")
|
36
|
-
.empty?
|
28
|
+
next if uninterrupt_quotes_around_xml_skip(n)
|
37
29
|
|
38
30
|
uninterrupt_quotes_around_xml1(n.previous)
|
39
31
|
end
|
40
32
|
end
|
41
33
|
|
34
|
+
def uninterrupt_quotes_around_xml_skip(elem)
|
35
|
+
!(/^['"]/.match?(elem.text) &&
|
36
|
+
elem.previous.ancestors("pre, tt, sourcecode, stem, figure, bibdata")
|
37
|
+
.empty? &&
|
38
|
+
((elem.previous.text.strip.empty? &&
|
39
|
+
!empty_tag_with_text_content?(elem.previous)) ||
|
40
|
+
elem.previous.name == "index"))
|
41
|
+
end
|
42
|
+
|
42
43
|
def uninterrupt_quotes_around_xml1(elem)
|
43
44
|
prev = elem.at(".//preceding::text()[1]") or return
|
44
45
|
/\S$/.match?(prev.text) or return
|
@@ -49,19 +50,40 @@ module Metanorma
|
|
49
50
|
prev.content = "#{prev.text}#{m[1]}"
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
-
(
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
def block?(elem)
|
54
|
+
%w(title name variant-title clause figure annex example introduction
|
55
|
+
foreword acknowledgements note li th td dt dd p quote label
|
56
|
+
abstract preferred admitted related deprecates field-of-application
|
57
|
+
usage-info expression pronunciation grammar-value domain
|
58
|
+
definition termnote termexample modification description
|
59
|
+
newcontent floating-title).include? elem.name
|
60
|
+
end
|
57
61
|
|
58
|
-
|
62
|
+
def empty_tag_with_text_content?(elem)
|
63
|
+
%w(eref xref termref link).include? elem.name
|
64
|
+
end
|
59
65
|
|
60
|
-
|
61
|
-
|
66
|
+
def dumb2smart_quotes(xmldoc)
|
67
|
+
prev = ""
|
68
|
+
xmldoc.traverse do |x|
|
69
|
+
block?(x) and prev = ""
|
70
|
+
empty_tag_with_text_content?(x) and prev = "dummy"
|
71
|
+
next unless x.text?
|
72
|
+
|
73
|
+
x.ancestors("pre, tt, sourcecode, stem, figure, bibdata").empty? and
|
74
|
+
dumb2smart_quotes1(x, prev)
|
75
|
+
prev = x.text if x.ancestors("index").empty?
|
62
76
|
end
|
63
77
|
end
|
64
78
|
|
79
|
+
def dumb2smart_quotes1(curr, prev)
|
80
|
+
/[-'"(<>]|\.\.|\dx/.match?(curr.text) or return
|
81
|
+
|
82
|
+
/^["']/.match?(curr.text) && prev.match?(/\S$/) and
|
83
|
+
curr.content = curr.text.sub(/^"/, "”").sub(/"’"/, "‘")
|
84
|
+
curr.replace(Metanorma::Utils::smartformat(curr.text))
|
85
|
+
end
|
86
|
+
|
65
87
|
def dumbquote_cleanup(xmldoc)
|
66
88
|
xmldoc.traverse do |n|
|
67
89
|
next unless n.text?
|
@@ -140,7 +140,7 @@ module Metanorma
|
|
140
140
|
parse_content_as :text
|
141
141
|
|
142
142
|
def process(parent, target, attrs)
|
143
|
-
/^(?<lang>[^-]*)(
|
143
|
+
/^(?<lang>[^-]*)(?:-(?<script>.*))?$/ =~ target
|
144
144
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
145
145
|
if script
|
146
146
|
%{<variant lang=#{lang} script=#{script}>#{out}</variant>}
|
@@ -5,13 +5,24 @@ module Metanorma
|
|
5
5
|
return reader if reader.eof?
|
6
6
|
|
7
7
|
lines = reader.readlines
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
/^embed::/.match?(line) ? embed(line, doc, reader, headings) : line
|
12
|
-
end.flatten
|
8
|
+
headings = lines.grep(/^== /).map(&:strip)
|
9
|
+
ret = lines.each_with_object({ lines: [], hdr: [] }) do |line, m|
|
10
|
+
process1(line, m, doc, reader, headings)
|
13
11
|
end
|
14
|
-
|
12
|
+
#doc.converter.embed_hdr = ret[:hdr]
|
13
|
+
doc.attributes["embed_hdr"] = ret[:hdr]
|
14
|
+
::Asciidoctor::Reader.new ret[:lines].flatten
|
15
|
+
end
|
16
|
+
|
17
|
+
def process1(line, acc, doc, reader, headings)
|
18
|
+
if /^embed::/.match?(line)
|
19
|
+
e = embed(line, doc, reader, headings)
|
20
|
+
acc[:lines] << e[:lines]
|
21
|
+
acc[:hdr] << e[:hdr]
|
22
|
+
else
|
23
|
+
acc[:lines] << line
|
24
|
+
end
|
25
|
+
acc
|
15
26
|
end
|
16
27
|
|
17
28
|
def filename(line, doc, reader)
|
@@ -27,26 +38,36 @@ module Metanorma
|
|
27
38
|
end
|
28
39
|
end
|
29
40
|
|
41
|
+
def read(inc_path)
|
42
|
+
::File.open inc_path, "r" do |fd|
|
43
|
+
readlines_safe(fd).map(&:chomp)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
30
47
|
def embed(line, doc, reader, headings)
|
31
48
|
inc_path = filename(line, doc, reader) or return line
|
32
49
|
lines = filter_sections(read(inc_path), headings)
|
33
50
|
doc = Asciidoctor::Document.new [], { safe: :safe }
|
34
51
|
reader = ::Asciidoctor::PreprocessorReader.new doc, lines
|
35
|
-
strip_header(reader.read_lines)
|
52
|
+
ret = strip_header(reader.read_lines)
|
53
|
+
embed_recurse(ret, doc, reader, headings)
|
36
54
|
end
|
37
55
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
56
|
+
def embed_recurse(ret, doc, reader, headings)
|
57
|
+
ret1 = ret[:lines].each_with_object({ lines: [], hdr: [] }) do |line, m|
|
58
|
+
process1(line, m, doc, reader, headings)
|
41
59
|
end
|
60
|
+
{ lines: ret1[:lines],
|
61
|
+
hdr: { text: ret[:hdr].join("\n"), child: ret1[:hdr] } }
|
42
62
|
end
|
43
63
|
|
44
64
|
def strip_header(lines)
|
45
|
-
return lines unless !lines.empty? &&
|
65
|
+
return { lines: lines, hdr: nil } unless !lines.empty? &&
|
66
|
+
lines.first.start_with?("= ")
|
46
67
|
|
47
68
|
skip = true
|
48
|
-
lines.each_with_object([]) do |l, m|
|
49
|
-
m << l
|
69
|
+
lines.each_with_object({ hdr: [], lines: [] }) do |l, m|
|
70
|
+
m[skip ? :hdr : :lines] << l
|
50
71
|
skip = false if !/\S/.match?(l)
|
51
72
|
end
|
52
73
|
end
|
@@ -22,9 +22,10 @@ module Metanorma
|
|
22
22
|
para.set_attr("name", "todo")
|
23
23
|
para.set_attr("caption", "TODO")
|
24
24
|
para.lines[0].sub!(/^TODO: /, "")
|
25
|
-
todo = Asciidoctor::Block
|
26
|
-
|
27
|
-
|
25
|
+
todo = Asciidoctor::Block
|
26
|
+
.new(parent, :admonition, attributes: para.attributes,
|
27
|
+
source: para.lines,
|
28
|
+
content_model: :compound)
|
28
29
|
parent.blocks[parent.blocks.index(para)] = todo
|
29
30
|
end
|
30
31
|
end
|
@@ -3,6 +3,10 @@ require "metanorma/processor"
|
|
3
3
|
module Metanorma
|
4
4
|
module Standoc
|
5
5
|
class Processor < Metanorma::Processor
|
6
|
+
class << self
|
7
|
+
attr_reader :asciidoctor_backend
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize # rubocop:disable Lint/MissingSuper
|
7
11
|
@short = :standoc
|
8
12
|
@input_format = :asciidoc
|
@@ -22,7 +26,8 @@ module Metanorma
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def html_path(file)
|
25
|
-
File.join(File.dirname(__FILE__), "..", "..", "isodoc", "html",
|
29
|
+
File.join(File.dirname(__FILE__), "..", "..", "isodoc", "html",
|
30
|
+
file)
|
26
31
|
end
|
27
32
|
|
28
33
|
def output(isodoc_node, inname, outname, format, options = {})
|
@@ -121,7 +121,7 @@ module Metanorma
|
|
121
121
|
t.formattedref **{ format: "application/x-isodoc+xml" } do |i|
|
122
122
|
i << ref_normalise_no_format(match[:text])
|
123
123
|
end
|
124
|
-
yr_match = /[:-](?<year>(19|20)[0-9][0-9])\b/.match(code[:id])
|
124
|
+
yr_match = /[:-](?<year>(?:19|20)[0-9][0-9])\b/.match(code[:id])
|
125
125
|
refitem_render1(match, code, t)
|
126
126
|
docnumber(t, code[:id]) unless /^\d+$|^\(.+\)$/.match?(code[:id])
|
127
127
|
conditional_date(t, yr_match || match, false)
|
@@ -149,7 +149,7 @@ module Metanorma
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def refitem1yr(code)
|
152
|
-
yr_match = /[:-](?<year>(19|20)[0-9][0-9])\b/.match(code)
|
152
|
+
yr_match = /[:-](?<year>(?:19|20)[0-9][0-9])\b/.match(code)
|
153
153
|
yr_match ? yr_match[:year] : nil
|
154
154
|
end
|
155
155
|
|
@@ -163,20 +163,20 @@ module Metanorma
|
|
163
163
|
|
164
164
|
ISO_REF =
|
165
165
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
166
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+|IEV)
|
167
|
-
(
|
166
|
+
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9-]+|IEV)
|
167
|
+
(?::(?<year>[0-9][0-9-]+))?\]</ref>,?\s*(?<text>.*)$}xm.freeze
|
168
168
|
|
169
169
|
ISO_REF_NO_YEAR =
|
170
170
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
171
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9-]+):
|
172
|
-
(
|
173
|
-
(
|
171
|
+
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9-]+):
|
172
|
+
(?:--|&\#821[12];)\]</ref>,?\s*
|
173
|
+
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
|
174
174
|
.freeze
|
175
175
|
|
176
176
|
ISO_REF_ALL_PARTS =
|
177
177
|
%r{^<ref\sid="(?<anchor>[^"]+)">
|
178
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(ISO|IEC)[^0-9]*\s[0-9]+)
|
179
|
-
(
|
178
|
+
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9]+)
|
179
|
+
(?::(?<year>--|&\#821[12];|[0-9][0-9-]+))?\s
|
180
180
|
\(all\sparts\)\]</ref>,?\s*
|
181
181
|
(<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?)?(?<text>.*)$}xm.freeze
|
182
182
|
|
@@ -2,7 +2,7 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Refs
|
4
4
|
def set_date_range(date, text)
|
5
|
-
matched = /^(?<from>[0-9]+)(
|
5
|
+
matched = /^(?<from>[0-9]+)(?:-+(?<to>[0-9]+))?$/.match text
|
6
6
|
return unless matched[:from]
|
7
7
|
|
8
8
|
if matched[:to]
|
@@ -113,10 +113,11 @@ module Metanorma
|
|
113
113
|
{ id: match[:anchor], type: "standard" }
|
114
114
|
end
|
115
115
|
|
116
|
-
MALFORMED_REF =
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
MALFORMED_REF = <<~REF.freeze
|
117
|
+
no anchor on reference, markup may be malformed: see
|
118
|
+
https://www.metanorma.com/author/topics/document-format/bibliography/ ,
|
119
|
+
https://www.metanorma.com/author/iso/topics/markup/#bibliographies
|
120
|
+
REF
|
120
121
|
|
121
122
|
def ref_normalise(ref)
|
122
123
|
ref.gsub(/&amp;/, "&").gsub(%r{^<em>(.*)</em>}, "\\1")
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true.
|
2
2
|
require "metanorma/standoc/utils"
|
3
3
|
|
4
|
-
|
5
4
|
module Metanorma
|
6
5
|
module Standoc
|
7
6
|
# Intelligent term lookup xml modifier
|
@@ -110,15 +109,15 @@ module Metanorma
|
|
110
109
|
if type == "term" || ((!type || node.parent.name == "related") && t)
|
111
110
|
node["target"] = t
|
112
111
|
elsif type == "symbol" ||
|
113
|
-
|
112
|
+
((!type || node.parent.name == "related") && s)
|
114
113
|
node["target"] = s
|
115
114
|
end
|
116
115
|
end
|
117
116
|
|
118
117
|
def replace_automatic_generated_ids_terms
|
119
118
|
r = xmldoc.xpath("//term").each.with_object({}) do |n, res|
|
120
|
-
normalize_id_and_memorize(n, res, "./preferred//name",
|
121
|
-
|
119
|
+
normalize_id_and_memorize(n, res, "./preferred//name", "term")
|
120
|
+
normalize_id_and_memorize(n, res, "./admitted//name", "term")
|
122
121
|
end
|
123
122
|
s = xmldoc.xpath("//definitions//dt").each.with_object({}) do |n, res|
|
124
123
|
normalize_id_and_memorize(n, res, ".", "symbol")
|
@@ -127,11 +126,13 @@ module Metanorma
|
|
127
126
|
end
|
128
127
|
|
129
128
|
def pref_secondary2primary
|
129
|
+
term = ""
|
130
130
|
xmldoc.xpath("//term").each.with_object({}) do |n, res|
|
131
131
|
n.xpath("./preferred//name").each_with_index do |p, i|
|
132
132
|
i.zero? and term = p.text
|
133
133
|
i.positive? and res[p.text] = term
|
134
134
|
end
|
135
|
+
n.xpath("./admitted//name").each { |p| res[p.text] = term }
|
135
136
|
end
|
136
137
|
end
|
137
138
|
|
@@ -141,7 +142,7 @@ module Metanorma
|
|
141
142
|
end
|
142
143
|
|
143
144
|
def normalize_id_and_memorize_init(node, res_table, text_selector, prefix)
|
144
|
-
term_text = normalize_ref_id(node.at(text_selector))
|
145
|
+
term_text = normalize_ref_id(node.at(text_selector)) or return
|
145
146
|
unless AUTOMATIC_GENERATED_ID_REGEXP.match(node["id"]).nil? &&
|
146
147
|
!node["id"].nil?
|
147
148
|
id = unique_text_id(term_text, prefix)
|
@@ -160,6 +161,8 @@ module Metanorma
|
|
160
161
|
end
|
161
162
|
|
162
163
|
def normalize_ref_id(term)
|
164
|
+
return nil if term.nil?
|
165
|
+
|
163
166
|
t = term.dup
|
164
167
|
t.xpath(".//index").map(&:remove)
|
165
168
|
Metanorma::Utils::to_ncname(t.text.strip.downcase
|
@@ -49,9 +49,79 @@ module Metanorma
|
|
49
49
|
iev_validate(doc.root)
|
50
50
|
concept_validate(doc, "concept", "refterm")
|
51
51
|
concept_validate(doc, "related", "preferred//name")
|
52
|
+
table_validate(doc)
|
52
53
|
@fatalerror.empty? or clean_abort(@fatalerror.join("\n"), doc.to_xml)
|
53
54
|
end
|
54
55
|
|
56
|
+
def table_validate(doc)
|
57
|
+
doc.xpath("//table[colgroup]").each do |t|
|
58
|
+
maxrowcols_validate(t, t.xpath("./colgroup/col").size)
|
59
|
+
end
|
60
|
+
doc.xpath("//table[.//*[@colspan] | .//*[@rowspan]]").each do |t|
|
61
|
+
maxrowcols_validate(t, max_td_count(t))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def max_td_count(table)
|
66
|
+
max = 0
|
67
|
+
table.xpath(".//tr").each do |tr|
|
68
|
+
n = tr.xpath("./td | ./th").size
|
69
|
+
max < n and max = n
|
70
|
+
end
|
71
|
+
max
|
72
|
+
end
|
73
|
+
|
74
|
+
def maxrowcols_validate(table, maxcols)
|
75
|
+
cells2d = table.xpath(".//tr").each_with_object([]) { |_r, m| m << {} }
|
76
|
+
table.xpath(".//tr").each_with_index do |tr, r|
|
77
|
+
curr = 0
|
78
|
+
tr.xpath("./td | ./th").each do |td|
|
79
|
+
curr = maxcols_validate1(td, r, curr, cells2d, maxcols)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
maxrows_validate(table, cells2d)
|
83
|
+
end
|
84
|
+
|
85
|
+
# code doesn't actually do anything, since Asciidoctor refuses to generate
|
86
|
+
# table with inconsistent column count
|
87
|
+
def maxcols_validate1(tcell, row, curr, cells2d, maxcols)
|
88
|
+
rs = tcell&.attr("rowspan")&.to_i || 1
|
89
|
+
cs = tcell&.attr("colspan")&.to_i || 1
|
90
|
+
curr = table_tracker_update(cells2d, row, curr, rs, cs)
|
91
|
+
maxcols_check(curr + cs - 1, maxcols, tcell)
|
92
|
+
curr + cs
|
93
|
+
end
|
94
|
+
|
95
|
+
def table_tracker_update(cells2d, row, curr, rowspan, colspan)
|
96
|
+
cells2d[row] ||= {}
|
97
|
+
while cells2d[row][curr]
|
98
|
+
curr += 1
|
99
|
+
end
|
100
|
+
(row..(row + rowspan - 1)).each do |y2|
|
101
|
+
cells2d[y2] ||= {}
|
102
|
+
(curr..(curr + colspan - 1)).each { |x2| cells2d[y2][x2] = 1 }
|
103
|
+
end
|
104
|
+
curr
|
105
|
+
end
|
106
|
+
|
107
|
+
def maxrows_validate(table, cells2d)
|
108
|
+
if cells2d.any? { |x| x.size != cells2d.first.size }
|
109
|
+
@log.add("Table", table,
|
110
|
+
"Table rows in table are inconsistent: check rowspan")
|
111
|
+
@fatalerror << "Table rows in table are inconsistent: check rowspan"
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
# if maxcols or maxrows negative, do not check them
|
116
|
+
def maxcols_check(col, maxcols, tcell)
|
117
|
+
if maxcols.positive? && col > maxcols
|
118
|
+
@log.add("Table", tcell, "Table exceeds maximum number of columns "\
|
119
|
+
"defined (#{maxcols})")
|
120
|
+
@fatalerror << "Table exceeds maximum number of columns defined "\
|
121
|
+
"(#{maxcols})"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
55
125
|
def norm_ref_validate(doc)
|
56
126
|
found = false
|
57
127
|
doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
|
@@ -71,10 +141,9 @@ module Metanorma
|
|
71
141
|
next if doc.at("//term[@id = '#{x['target']}']")
|
72
142
|
next if doc.at("//definitions//dt[@id = '#{x['target']}']")
|
73
143
|
|
74
|
-
ref = x&.at("../#{refterm}")&.text
|
75
144
|
@log.add("Anchors", x,
|
76
|
-
"#{tag.capitalize} #{
|
77
|
-
"#{x['target']}, which is not a term or symbol")
|
145
|
+
"#{tag.capitalize} #{x&.at("../#{refterm}")&.text} is "\
|
146
|
+
"pointing to #{x['target']}, which is not a term or symbol")
|
78
147
|
found = true
|
79
148
|
end
|
80
149
|
found and
|
@@ -122,23 +191,23 @@ module Metanorma
|
|
122
191
|
|
123
192
|
SVG_NS = "http://www.w3.org/2000/svg".freeze
|
124
193
|
|
194
|
+
WILDCARD_ATTRS =
|
195
|
+
"//*[@format] | //stem | //bibdata//description | "\
|
196
|
+
"//formattedref | //bibdata//note | //bibdata/abstract | "\
|
197
|
+
"//bibitem/abstract | //bibitem/note | //misc-container".freeze
|
198
|
+
|
125
199
|
# RelaxNG cannot cope well with wildcard attributes. So we strip
|
126
200
|
# any attributes from FormattedString instances (which can contain
|
127
201
|
# xs:any markup, and are signalled with @format) before validation.
|
128
202
|
def formattedstr_strip(doc)
|
129
|
-
doc.xpath("
|
130
|
-
"//formattedref | //bibdata//note | //bibdata/abstract | "\
|
131
|
-
"//bibitem/abstract | //bibitem/note | //misc-container",
|
132
|
-
"m" => SVG_NS).each do |n|
|
203
|
+
doc.xpath(WILDCARD_ATTRS, "m" => SVG_NS).each do |n|
|
133
204
|
n.elements.each do |e|
|
134
205
|
e.traverse do |e1|
|
135
206
|
e1.element? and e1.each { |k, _v| e1.delete(k) }
|
136
207
|
end
|
137
208
|
end
|
138
209
|
end
|
139
|
-
doc.xpath("//m:svg", "m" => SVG_NS).each
|
140
|
-
n.replace("<svg/>")
|
141
|
-
end
|
210
|
+
doc.xpath("//m:svg", "m" => SVG_NS).each { |n| n.replace("<svg/>") }
|
142
211
|
doc
|
143
212
|
end
|
144
213
|
|
data/metanorma-standoc.gemspec
CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
30
30
|
spec.add_dependency "iev", "~> 0.3.0"
|
31
31
|
spec.add_dependency "isodoc", "~> 2.0.0"
|
32
|
-
spec.add_dependency "metanorma-plugin-datastruct"
|
32
|
+
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
33
33
|
spec.add_dependency "metanorma-plugin-lutaml"
|
34
34
|
spec.add_dependency "ruby-jing"
|
35
35
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
@@ -52,6 +52,6 @@ Gem::Specification.new do |spec|
|
|
52
52
|
spec.add_development_dependency "sassc", "2.4.0"
|
53
53
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
54
54
|
spec.add_development_dependency "timecop", "~> 0.9"
|
55
|
-
spec.add_development_dependency "vcr", "~>
|
55
|
+
spec.add_development_dependency "vcr", "~> 6.1.0"
|
56
56
|
spec.add_development_dependency "webmock"
|
57
57
|
end
|
data/spec/assets/a2.adoc
CHANGED
data/spec/assets/a3.adoc
CHANGED
@@ -9,13 +9,21 @@ RSpec.describe Metanorma::Standoc do
|
|
9
9
|
== "Quotation" A's
|
10
10
|
|
11
11
|
'24:00:00'.
|
12
|
+
|
13
|
+
_emphasis_ *strong* `monospace` "double quote" 'single quote'
|
12
14
|
INPUT
|
13
15
|
output = <<~OUTPUT
|
14
|
-
|
16
|
+
#{BLANK_HDR}
|
15
17
|
<sections>
|
16
18
|
<clause id="_" inline-header="false" obligation="normative">
|
17
19
|
<title>“Quotation” A’s</title>
|
18
20
|
<p id='_'>‘24:00:00’.</p>
|
21
|
+
<p id='_'>
|
22
|
+
<em>emphasis</em>
|
23
|
+
<strong>strong</strong>
|
24
|
+
<tt>monospace</tt>
|
25
|
+
“double quote” ‘single quote’
|
26
|
+
</p>
|
19
27
|
</clause>
|
20
28
|
</sections>
|
21
29
|
</standard-document>
|
@@ -149,6 +157,10 @@ RSpec.describe Metanorma::Standoc do
|
|
149
157
|
input = <<~INPUT
|
150
158
|
#{ASCIIDOC_BLANK_HDR}
|
151
159
|
|
160
|
+
"*word*",
|
161
|
+
|
162
|
+
"link:http://example.com[]",
|
163
|
+
|
152
164
|
"((ppt))",
|
153
165
|
|
154
166
|
"((ppm))", "((ppt))"
|
@@ -160,16 +172,16 @@ RSpec.describe Metanorma::Standoc do
|
|
160
172
|
....
|
161
173
|
INPUT
|
162
174
|
output = <<~OUTPUT
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
175
|
+
#{BLANK_HDR}
|
176
|
+
<sections>
|
177
|
+
<p id='_'>“<strong>word</strong>”,</p>
|
178
|
+
<p id='_'>“<link target='http://example.com'/>”,</p>
|
179
|
+
<p id='_'>“ppt”,
|
167
180
|
<index>
|
168
181
|
<primary>ppt</primary>
|
169
182
|
</index>
|
170
183
|
</p>
|
171
|
-
|
172
|
-
“ppm”,
|
184
|
+
<p id='_'>“ppm”,
|
173
185
|
<index>
|
174
186
|
<primary>ppm</primary>
|
175
187
|
</index>
|
@@ -178,12 +190,11 @@ RSpec.describe Metanorma::Standoc do
|
|
178
190
|
<primary>ppt</primary>
|
179
191
|
</index>
|
180
192
|
</p>
|
181
|
-
|
182
|
-
“ppm
|
193
|
+
<p id='_'>“ppm
|
183
194
|
<index>
|
184
195
|
<primary>ppm</primary>
|
185
196
|
</index>
|
186
|
-
&#
|
197
|
+
” 
|
187
198
|
</p>
|
188
199
|
<figure id='_'>
|
189
200
|
<pre id='_'>((ppm))",</pre>
|
@@ -3,6 +3,7 @@ require "relaton_iec"
|
|
3
3
|
require "fileutils"
|
4
4
|
|
5
5
|
RSpec.describe Metanorma::Standoc do
|
6
|
+
=begin
|
6
7
|
it "processes term and designation metadata and term sources" do
|
7
8
|
input = <<~INPUT
|
8
9
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -180,8 +181,9 @@ RSpec.describe Metanorma::Standoc do
|
|
180
181
|
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
181
182
|
.to be_equivalent_to xmlpp(output)
|
182
183
|
end
|
183
|
-
|
184
|
-
it "permits multiple preferred terms
|
184
|
+
=end
|
185
|
+
it "permits multiple preferred terms and admitted terms, "\
|
186
|
+
"and treats them as synonyms in concepts" do
|
185
187
|
input = <<~INPUT
|
186
188
|
#{ASCIIDOC_BLANK_HDR}
|
187
189
|
== Terms and Definitions
|
@@ -209,6 +211,9 @@ RSpec.describe Metanorma::Standoc do
|
|
209
211
|
{{First Designation}}
|
210
212
|
|
211
213
|
{{Second Designation}}
|
214
|
+
|
215
|
+
{{Third Designation}}
|
216
|
+
|
212
217
|
INPUT
|
213
218
|
output = <<~OUTPUT
|
214
219
|
#{BLANK_HDR}
|
@@ -279,11 +284,18 @@ RSpec.describe Metanorma::Standoc do
|
|
279
284
|
</p>
|
280
285
|
<p id='_'>
|
281
286
|
<concept>
|
282
|
-
<refterm>
|
287
|
+
<refterm>First Designation</refterm>
|
283
288
|
<renderterm>Second Designation</renderterm>
|
284
289
|
<xref target='term-first-designation'/>
|
285
290
|
</concept>
|
286
291
|
</p>
|
292
|
+
<p id='_'>
|
293
|
+
<concept>
|
294
|
+
<refterm>First Designation</refterm>
|
295
|
+
<renderterm>Third Designation</renderterm>
|
296
|
+
<xref target='term-first-designation'/>
|
297
|
+
</concept>
|
298
|
+
</p>
|
287
299
|
</clause>
|
288
300
|
</sections>
|
289
301
|
</standard-document>
|
@@ -1364,8 +1364,70 @@ RSpec.describe Metanorma::Standoc do
|
|
1364
1364
|
embed::spec/assets/a1.adoc[]
|
1365
1365
|
INPUT
|
1366
1366
|
output = <<~OUTPUT
|
1367
|
-
#{
|
1368
|
-
|
1367
|
+
<standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
|
1368
|
+
<bibdata type='standard'>
|
1369
|
+
<title language='en' format='text/plain'>Document title</title>
|
1370
|
+
<language>en</language>
|
1371
|
+
<script>Latn</script>
|
1372
|
+
<status>
|
1373
|
+
<stage>published</stage>
|
1374
|
+
</status>
|
1375
|
+
<copyright>
|
1376
|
+
<from>2022</from>
|
1377
|
+
</copyright>
|
1378
|
+
<ext>
|
1379
|
+
<doctype>article</doctype>
|
1380
|
+
</ext>
|
1381
|
+
<relation type='derivedFrom'>
|
1382
|
+
<bibitem>
|
1383
|
+
<title language='en' format='text/plain'>A2</title>
|
1384
|
+
<language>en</language>
|
1385
|
+
<script>Latn</script>
|
1386
|
+
<status>
|
1387
|
+
<stage>published</stage>
|
1388
|
+
</status>
|
1389
|
+
<copyright>
|
1390
|
+
<from>2022</from>
|
1391
|
+
</copyright>
|
1392
|
+
<ext>
|
1393
|
+
<doctype>article</doctype>
|
1394
|
+
</ext>
|
1395
|
+
<relation type='derivedFrom'>
|
1396
|
+
<bibitem>
|
1397
|
+
<title language='en' format='text/plain'>A3</title>
|
1398
|
+
<language>en</language>
|
1399
|
+
<script>Latn</script>
|
1400
|
+
<status>
|
1401
|
+
<stage>published</stage>
|
1402
|
+
</status>
|
1403
|
+
<copyright>
|
1404
|
+
<from>2022</from>
|
1405
|
+
</copyright>
|
1406
|
+
<ext>
|
1407
|
+
<doctype>article</doctype>
|
1408
|
+
</ext>
|
1409
|
+
</bibitem>
|
1410
|
+
</relation>
|
1411
|
+
<relation type='derivedFrom'>
|
1412
|
+
<bibitem>
|
1413
|
+
<title language='en' format='text/plain'>A3a</title>
|
1414
|
+
<language>en</language>
|
1415
|
+
<script>Latn</script>
|
1416
|
+
<status>
|
1417
|
+
<stage>published</stage>
|
1418
|
+
</status>
|
1419
|
+
<copyright>
|
1420
|
+
<from>2022</from>
|
1421
|
+
</copyright>
|
1422
|
+
<ext>
|
1423
|
+
<doctype>article</doctype>
|
1424
|
+
</ext>
|
1425
|
+
</bibitem>
|
1426
|
+
</relation>
|
1427
|
+
</bibitem>
|
1428
|
+
</relation>
|
1429
|
+
</bibdata>
|
1430
|
+
<sections>
|
1369
1431
|
<clause id='clause1' inline-header='false' obligation='normative'>
|
1370
1432
|
<title>Clause</title>
|
1371
1433
|
</clause>
|
@@ -1381,6 +1443,10 @@ RSpec.describe Metanorma::Standoc do
|
|
1381
1443
|
<title>Clause 3</title>
|
1382
1444
|
<p id='_'>X</p>
|
1383
1445
|
</clause>
|
1446
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
1447
|
+
<title>Clause 3a</title>
|
1448
|
+
<p id='_'>X</p>
|
1449
|
+
</clause>
|
1384
1450
|
<clause id='_' inline-header='false' obligation='normative'>
|
1385
1451
|
<title>Clause 4</title>
|
1386
1452
|
<p id='_'>X</p>
|
@@ -478,6 +478,114 @@ RSpec.describe Metanorma::Standoc do
|
|
478
478
|
expect(File.exist?("test.xml")).to be false
|
479
479
|
end
|
480
480
|
|
481
|
+
it "does not warn and abort if columns and rows not out of bounds" do
|
482
|
+
FileUtils.rm_f "test.xml"
|
483
|
+
FileUtils.rm_f "test.err"
|
484
|
+
begin
|
485
|
+
input = <<~INPUT
|
486
|
+
= Document title
|
487
|
+
Author
|
488
|
+
:docfile: test.adoc
|
489
|
+
:nodoc:
|
490
|
+
|
491
|
+
== Clause
|
492
|
+
|
493
|
+
[cols="1,1,1,1"]
|
494
|
+
|===
|
495
|
+
3.2+| a | a
|
496
|
+
|
497
|
+
| a
|
498
|
+
| a | a | a | a
|
499
|
+
|===
|
500
|
+
INPUT
|
501
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }.not_to raise_error(SystemExit)
|
502
|
+
rescue SystemExit
|
503
|
+
end
|
504
|
+
expect(File.read("test.err"))
|
505
|
+
.not_to include "Table exceeds maximum number of columns defined"
|
506
|
+
expect(File.read("test.err"))
|
507
|
+
.not_to include "Table rows in table are inconsistent: check rowspan"
|
508
|
+
end
|
509
|
+
|
510
|
+
xit "warns and aborts if columns out of bounds against colgroup" do
|
511
|
+
FileUtils.rm_f "test.xml"
|
512
|
+
FileUtils.rm_f "test.err"
|
513
|
+
begin
|
514
|
+
input = <<~INPUT
|
515
|
+
= Document title
|
516
|
+
Author
|
517
|
+
:docfile: test.adoc
|
518
|
+
:nodoc:
|
519
|
+
|
520
|
+
[cols="1,1,1,1"]
|
521
|
+
|===
|
522
|
+
5+| a
|
523
|
+
|
524
|
+
| a 4+| a
|
525
|
+
| a | a |a |a
|
526
|
+
|===
|
527
|
+
INPUT
|
528
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
|
529
|
+
rescue SystemExit
|
530
|
+
end
|
531
|
+
expect(File.read("test.err"))
|
532
|
+
.to include "Table exceeds maximum number of columns defined (4)"
|
533
|
+
expect(File.read("test.err"))
|
534
|
+
.not_to include "Table rows in table are inconsistent: check rowspan"
|
535
|
+
end
|
536
|
+
|
537
|
+
xit "warns and aborts if columns out of bounds against cell count per row" do
|
538
|
+
FileUtils.rm_f "test.xml"
|
539
|
+
FileUtils.rm_f "test.err"
|
540
|
+
begin
|
541
|
+
input = <<~INPUT
|
542
|
+
= Document title
|
543
|
+
Author
|
544
|
+
:docfile: test.adoc
|
545
|
+
:nodoc:
|
546
|
+
|
547
|
+
|===
|
548
|
+
2.3+| a | a
|
549
|
+
|
550
|
+
| a | a | a
|
551
|
+
| a | a | a
|
552
|
+
|===
|
553
|
+
INPUT
|
554
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
|
555
|
+
rescue SystemExit
|
556
|
+
end
|
557
|
+
expect(File.read("test.err"))
|
558
|
+
.to include "Table exceeds maximum number of columns defined (3)"
|
559
|
+
expect(File.read("test.err"))
|
560
|
+
.not_to include "Table rows in table are inconsistent: check rowspan"
|
561
|
+
end
|
562
|
+
|
563
|
+
it "warns and aborts if rows out of bounds" do
|
564
|
+
FileUtils.rm_f "test.xml"
|
565
|
+
FileUtils.rm_f "test.err"
|
566
|
+
begin
|
567
|
+
input = <<~INPUT
|
568
|
+
= Document title
|
569
|
+
Author
|
570
|
+
:docfile: test.adoc
|
571
|
+
:nodoc:
|
572
|
+
|
573
|
+
|===
|
574
|
+
.4+| a | a | a | a
|
575
|
+
|
576
|
+
| a | a | a
|
577
|
+
| a | a | a
|
578
|
+
|===
|
579
|
+
INPUT
|
580
|
+
expect { Asciidoctor.convert(input, *OPTIONS) }.to raise_error(SystemExit)
|
581
|
+
rescue SystemExit
|
582
|
+
end
|
583
|
+
expect(File.read("test.err"))
|
584
|
+
.not_to include "Table exceeds maximum number of columns defined"
|
585
|
+
expect(File.read("test.err"))
|
586
|
+
.to include "Table rows in table are inconsistent: check rowspan"
|
587
|
+
end
|
588
|
+
|
481
589
|
it "err file succesfully created for docfile path" do
|
482
590
|
FileUtils.rm_rf "test"
|
483
591
|
FileUtils.mkdir_p "test"
|
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.0.
|
4
|
+
version: 2.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: metanorma-plugin-datastruct
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.2.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: 0.2.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: metanorma-plugin-lutaml
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -352,14 +352,14 @@ dependencies:
|
|
352
352
|
requirements:
|
353
353
|
- - "~>"
|
354
354
|
- !ruby/object:Gem::Version
|
355
|
-
version:
|
355
|
+
version: 6.1.0
|
356
356
|
type: :development
|
357
357
|
prerelease: false
|
358
358
|
version_requirements: !ruby/object:Gem::Requirement
|
359
359
|
requirements:
|
360
360
|
- - "~>"
|
361
361
|
- !ruby/object:Gem::Version
|
362
|
-
version:
|
362
|
+
version: 6.1.0
|
363
363
|
- !ruby/object:Gem::Dependency
|
364
364
|
name: webmock
|
365
365
|
requirement: !ruby/object:Gem::Requirement
|
@@ -518,6 +518,7 @@ files:
|
|
518
518
|
- spec/assets/a1.adoc
|
519
519
|
- spec/assets/a2.adoc
|
520
520
|
- spec/assets/a3.adoc
|
521
|
+
- spec/assets/a3a.adoc
|
521
522
|
- spec/assets/a4.adoc
|
522
523
|
- spec/assets/boilerplate.xml
|
523
524
|
- spec/assets/codes.yml
|
@@ -643,7 +644,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
643
644
|
- !ruby/object:Gem::Version
|
644
645
|
version: '0'
|
645
646
|
requirements: []
|
646
|
-
rubygems_version: 3.
|
647
|
+
rubygems_version: 3.3.9
|
647
648
|
signing_key:
|
648
649
|
specification_version: 4
|
649
650
|
summary: metanorma-standoc realises standards following the Metanorma standoc model
|