metanorma-standoc 1.10.4.1 → 1.10.8
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/README.adoc +19 -23
- data/lib/asciidoctor/standoc/base.rb +11 -13
- data/lib/asciidoctor/standoc/basicdoc.rng +21 -4
- data/lib/asciidoctor/standoc/blocks.rb +27 -22
- data/lib/asciidoctor/standoc/blocks_notes.rb +17 -22
- data/lib/asciidoctor/standoc/cleanup.rb +38 -71
- data/lib/asciidoctor/standoc/cleanup_block.rb +5 -70
- data/lib/asciidoctor/standoc/cleanup_image.rb +6 -7
- data/lib/asciidoctor/standoc/cleanup_inline.rb +27 -98
- data/lib/asciidoctor/standoc/cleanup_maths.rb +113 -21
- data/lib/asciidoctor/standoc/cleanup_ref.rb +5 -0
- data/lib/asciidoctor/standoc/cleanup_reqt.rb +56 -18
- data/lib/asciidoctor/standoc/cleanup_section.rb +1 -0
- data/lib/asciidoctor/standoc/cleanup_section_names.rb +31 -14
- data/lib/asciidoctor/standoc/cleanup_table.rb +68 -0
- data/lib/asciidoctor/standoc/cleanup_terms.rb +1 -1
- data/lib/asciidoctor/standoc/cleanup_text.rb +73 -0
- data/lib/asciidoctor/standoc/cleanup_xref.rb +107 -0
- data/lib/asciidoctor/standoc/converter.rb +13 -0
- data/lib/asciidoctor/standoc/isodoc.rng +241 -61
- data/lib/asciidoctor/standoc/lists.rb +15 -15
- data/lib/asciidoctor/standoc/macros.rb +14 -43
- data/lib/asciidoctor/standoc/macros_note.rb +45 -0
- data/lib/asciidoctor/standoc/macros_terms.rb +33 -15
- data/lib/asciidoctor/standoc/reqt.rb +2 -2
- data/lib/asciidoctor/standoc/reqt.rng +23 -2
- data/lib/asciidoctor/standoc/table.rb +22 -20
- data/lib/asciidoctor/standoc/terms.rb +9 -1
- data/lib/asciidoctor/standoc/validate.rb +23 -14
- data/lib/asciidoctor/standoc/validate_section.rb +5 -2
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/asciidoctor/base_spec.rb +0 -33
- data/spec/asciidoctor/blank_spec.rb +37 -0
- data/spec/asciidoctor/blocks_spec.rb +151 -30
- data/spec/asciidoctor/cleanup_blocks_spec.rb +1018 -0
- data/spec/asciidoctor/cleanup_sections_spec.rb +207 -0
- data/spec/asciidoctor/cleanup_spec.rb +193 -1078
- data/spec/asciidoctor/inline_spec.rb +36 -0
- data/spec/asciidoctor/isobib_cache_spec.rb +8 -8
- data/spec/asciidoctor/lists_spec.rb +6 -6
- data/spec/asciidoctor/macros_plantuml_spec.rb +1 -1
- data/spec/asciidoctor/macros_spec.rb +41 -26
- data/spec/asciidoctor/refs_dl_spec.rb +1 -1
- data/spec/asciidoctor/refs_spec.rb +220 -444
- data/spec/asciidoctor/section_spec.rb +1 -1
- data/spec/asciidoctor/validate_spec.rb +51 -0
- data/spec/assets/xref_error.adoc +1 -0
- data/spec/fixtures/datamodel_description_sections_tree.xml +24 -24
- data/spec/spec_helper.rb +5 -7
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +231 -143
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +152 -0
- data/spec/vcr_cassettes/isobib_get_123.yml +52 -36
- data/spec/vcr_cassettes/isobib_get_123_1.yml +103 -71
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +112 -80
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +50 -34
- data/spec/vcr_cassettes/isobib_get_124.yml +51 -35
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +16 -16
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +70 -46
- metadata +11 -4
@@ -6,6 +6,7 @@ require "csv"
|
|
6
6
|
require_relative "./macros_plantuml"
|
7
7
|
require_relative "./macros_terms"
|
8
8
|
require_relative "./macros_form"
|
9
|
+
require_relative "./macros_note"
|
9
10
|
require_relative "./datamodel/attributes_table_preprocessor"
|
10
11
|
require_relative "./datamodel/diagram_preprocessor"
|
11
12
|
require "metanorma-plugin-datastruct"
|
@@ -41,7 +42,7 @@ module Asciidoctor
|
|
41
42
|
def process(_parent, target, attr)
|
42
43
|
args = preprocess_attrs(attr) or return
|
43
44
|
ret = "<index-xref also='#{target == 'also'}'>"\
|
44
|
-
|
45
|
+
"<primary>#{args[:primary]}</primary>"
|
45
46
|
ret += "<secondary>#{args[:secondary]}</secondary>" if args[:secondary]
|
46
47
|
ret += "<tertiary>#{args[:tertiary]}</tertiary>" if args[:tertiary]
|
47
48
|
ret + "<target>#{args[:target]}</target></index-xref>"
|
@@ -50,7 +51,7 @@ module Asciidoctor
|
|
50
51
|
|
51
52
|
class IndexRangeInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
52
53
|
use_dsl
|
53
|
-
named "index-range"
|
54
|
+
named :"index-range"
|
54
55
|
parse_content_as :text
|
55
56
|
|
56
57
|
def process(parent, target, attr)
|
@@ -121,35 +122,6 @@ module Asciidoctor
|
|
121
122
|
end
|
122
123
|
end
|
123
124
|
|
124
|
-
class ToDoAdmonitionBlock < Extensions::BlockProcessor
|
125
|
-
use_dsl
|
126
|
-
named :TODO
|
127
|
-
on_contexts :example, :paragraph
|
128
|
-
|
129
|
-
def process(parent, reader, attrs)
|
130
|
-
attrs["name"] = "todo"
|
131
|
-
attrs["caption"] = "TODO"
|
132
|
-
create_block(parent, :admonition, reader.lines, attrs,
|
133
|
-
content_model: :compound)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
class ToDoInlineAdmonitionBlock < Extensions::Treeprocessor
|
138
|
-
def process(document)
|
139
|
-
(document.find_by context: :paragraph).each do |para|
|
140
|
-
next unless /^TODO: /.match? para.lines[0]
|
141
|
-
|
142
|
-
parent = para.parent
|
143
|
-
para.set_attr("name", "todo")
|
144
|
-
para.set_attr("caption", "TODO")
|
145
|
-
para.lines[0].sub!(/^TODO: /, "")
|
146
|
-
todo = Block.new(parent, :admonition, attributes: para.attributes,
|
147
|
-
source: para.lines, content_model: :compound)
|
148
|
-
parent.blocks[parent.blocks.index(para)] = todo
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
125
|
class AutonumberInlineMacro < Extensions::InlineMacroProcessor
|
154
126
|
use_dsl
|
155
127
|
named :autonumber
|
@@ -177,18 +149,6 @@ module Asciidoctor
|
|
177
149
|
end
|
178
150
|
end
|
179
151
|
|
180
|
-
class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
181
|
-
use_dsl
|
182
|
-
named :footnoteblock
|
183
|
-
parse_content_as :text
|
184
|
-
using_format :short
|
185
|
-
|
186
|
-
def process(parent, _target, attrs)
|
187
|
-
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
188
|
-
%{<footnoteblock>#{out}</footnoteblock>}
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
152
|
class AddMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
193
153
|
use_dsl
|
194
154
|
named :add
|
@@ -229,5 +189,16 @@ module Asciidoctor
|
|
229
189
|
"<toc>#{content}</toc>"
|
230
190
|
end
|
231
191
|
end
|
192
|
+
|
193
|
+
class PassInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
194
|
+
use_dsl
|
195
|
+
named :"pass-format"
|
196
|
+
|
197
|
+
def process(parent, target, attrs)
|
198
|
+
format = target || "metanorma"
|
199
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs[1]).convert
|
200
|
+
%{<passthrough formats="#{format}">#{out}</passthrough>}
|
201
|
+
end
|
202
|
+
end
|
232
203
|
end
|
233
204
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Asciidoctor
|
2
|
+
module Standoc
|
3
|
+
class ToDoAdmonitionBlock < Extensions::BlockProcessor
|
4
|
+
use_dsl
|
5
|
+
named :TODO
|
6
|
+
on_contexts :example, :paragraph
|
7
|
+
|
8
|
+
def process(parent, reader, attrs)
|
9
|
+
attrs["name"] = "todo"
|
10
|
+
attrs["caption"] = "TODO"
|
11
|
+
create_block(parent, :admonition, reader.lines, attrs,
|
12
|
+
content_model: :compound)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class ToDoInlineAdmonitionBlock < Extensions::Treeprocessor
|
17
|
+
def process(document)
|
18
|
+
(document.find_by context: :paragraph).each do |para|
|
19
|
+
next unless /^TODO: /.match? para.lines[0]
|
20
|
+
|
21
|
+
parent = para.parent
|
22
|
+
para.set_attr("name", "todo")
|
23
|
+
para.set_attr("caption", "TODO")
|
24
|
+
para.lines[0].sub!(/^TODO: /, "")
|
25
|
+
todo = Block.new(parent, :admonition, attributes: para.attributes,
|
26
|
+
source: para.lines,
|
27
|
+
content_model: :compound)
|
28
|
+
parent.blocks[parent.blocks.index(para)] = todo
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class FootnoteBlockInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
34
|
+
use_dsl
|
35
|
+
named :footnoteblock
|
36
|
+
parse_content_as :text
|
37
|
+
using_format :short
|
38
|
+
|
39
|
+
def process(parent, _target, attrs)
|
40
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
41
|
+
%{<footnoteblock>#{out}</footnoteblock>}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -81,15 +81,24 @@ module Asciidoctor
|
|
81
81
|
def preprocess_attrs(target)
|
82
82
|
m = /^(?<id><<.+?>>)?(?<rest>.*)$/.match(target)
|
83
83
|
ret = { id: m[:id]&.sub(/^<</, "")&.sub(/>>$/, "") }
|
84
|
-
if m2 = /^(?<rest>.*?)(?<opt>,
|
85
|
-
|
84
|
+
if m2 = /^(?<rest>.*?)(?<opt>,opt(ion)?s=.+)$/
|
85
|
+
.match(m[:rest].sub(/^,/, ""))
|
86
|
+
ret[:opt] = CSV.parse_line(m2[:opt].sub(/^,opt(ion)?s=/, "")
|
86
87
|
.sub(/^"(.+)"$/, "\\1").sub(/^'(.+)'$/, "\\1"))
|
87
|
-
|
88
|
+
begin
|
89
|
+
attrs = CSV.parse_line(m2[:rest]) || []
|
90
|
+
rescue StandardError
|
91
|
+
raise "error processing #{m2[:rest]} as CSV"
|
92
|
+
end
|
88
93
|
else
|
89
|
-
|
94
|
+
begin
|
95
|
+
attrs = CSV.parse_line(m[:rest].sub(/^,/, "")) || []
|
96
|
+
rescue StandardError
|
97
|
+
raise "error processing #{m[:rest]} as CSV"
|
98
|
+
end
|
90
99
|
end
|
91
100
|
ret.merge(term: attrs[0], word: attrs[1] || attrs[0],
|
92
|
-
|
101
|
+
render: attrs[2])
|
93
102
|
end
|
94
103
|
|
95
104
|
def generate_attrs(opts)
|
@@ -98,21 +107,30 @@ module Asciidoctor
|
|
98
107
|
opts.include?("noref") and ret += " ref='false'"
|
99
108
|
opts.include?("ital") and ret += " ital='true'"
|
100
109
|
opts.include?("ref") and ret += " ref='true'"
|
110
|
+
opts.include?("nolinkmention") and ret += " linkmention='false'"
|
111
|
+
opts.include?("linkmention") and ret += " linkmention='true'"
|
112
|
+
opts.include?("nolinkref") and ret += " linkref='false'"
|
113
|
+
opts.include?("linkref") and ret += " linkref='true'"
|
101
114
|
ret
|
102
115
|
end
|
103
116
|
|
104
117
|
def process(parent, target, _attrs)
|
105
118
|
attrs = preprocess_attrs(target)
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
"
|
119
|
+
term = Asciidoctor::Inline.new(parent, :quoted,
|
120
|
+
attrs[:term]).convert
|
121
|
+
word = Asciidoctor::Inline.new(parent, :quoted,
|
122
|
+
attrs[:word]).convert
|
123
|
+
xref = Asciidoctor::Inline.new(parent, :quoted,
|
124
|
+
attrs[:render]).convert
|
125
|
+
opt = generate_attrs(attrs[:opt] || [])
|
126
|
+
if attrs[:id] then "<concept#{opt} key='#{attrs[:id]}'><refterm>"\
|
127
|
+
"#{term}</refterm><renderterm>#{word}</renderterm>"\
|
128
|
+
"<xrefrender>#{xref}</xrefrender></concept>"
|
129
|
+
else "<concept#{opt}><termxref>#{term}</termxref><renderterm>"\
|
130
|
+
"#{word}</renderterm><xrefrender>#{xref}</xrefrender></concept>"
|
131
|
+
end
|
132
|
+
rescue StandardError => e
|
133
|
+
raise("processing {{#{target}}}: #{e.message}")
|
116
134
|
end
|
117
135
|
end
|
118
136
|
end
|
@@ -7,8 +7,8 @@ module Asciidoctor
|
|
7
7
|
module Standoc
|
8
8
|
module Blocks
|
9
9
|
def reqt_subpart(name)
|
10
|
-
%w(specification measurement-target verification import label
|
11
|
-
component subject inherit classification
|
10
|
+
%w(specification measurement-target verification import label title
|
11
|
+
description component subject inherit classification).include? name
|
12
12
|
end
|
13
13
|
|
14
14
|
def reqt_subpart_attrs(node, name)
|
@@ -58,6 +58,14 @@
|
|
58
58
|
<optional>
|
59
59
|
<attribute name="type"/>
|
60
60
|
</optional>
|
61
|
+
<optional>
|
62
|
+
<attribute name="tag"/>
|
63
|
+
</optional>
|
64
|
+
<optional>
|
65
|
+
<attribute name="multilingual-rendering">
|
66
|
+
<ref name="MultilingualRenderingType"/>
|
67
|
+
</attribute>
|
68
|
+
</optional>
|
61
69
|
<optional>
|
62
70
|
<ref name="reqtitle"/>
|
63
71
|
</optional>
|
@@ -101,7 +109,9 @@
|
|
101
109
|
</define>
|
102
110
|
<define name="label">
|
103
111
|
<element name="label">
|
104
|
-
<
|
112
|
+
<oneOrMore>
|
113
|
+
<ref name="TextElement"/>
|
114
|
+
</oneOrMore>
|
105
115
|
</element>
|
106
116
|
</define>
|
107
117
|
<define name="subject">
|
@@ -175,8 +185,19 @@
|
|
175
185
|
<data type="boolean"/>
|
176
186
|
</attribute>
|
177
187
|
</optional>
|
188
|
+
<optional>
|
189
|
+
<attribute name="tag"/>
|
190
|
+
</optional>
|
191
|
+
<optional>
|
192
|
+
<attribute name="multilingual-rendering">
|
193
|
+
<ref name="MultilingualRenderingType"/>
|
194
|
+
</attribute>
|
195
|
+
</optional>
|
178
196
|
<oneOrMore>
|
179
|
-
<
|
197
|
+
<choice>
|
198
|
+
<ref name="BasicBlock"/>
|
199
|
+
<ref name="component"/>
|
200
|
+
</choice>
|
180
201
|
</oneOrMore>
|
181
202
|
</define>
|
182
203
|
<define name="ObligationType">
|
@@ -2,15 +2,15 @@ module Asciidoctor
|
|
2
2
|
module Standoc
|
3
3
|
module Table
|
4
4
|
def table_attrs(node)
|
5
|
-
keep_attrs(node)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
keep_attrs(node)
|
6
|
+
.merge(id: Metanorma::Utils::anchor_or_uuid(node),
|
7
|
+
headerrows: node.attr("headerrows"),
|
8
|
+
unnumbered: node.option?("unnumbered") ? "true" : nil,
|
9
|
+
number: node.attr("number"),
|
10
|
+
subsequence: node.attr("subsequence"),
|
11
|
+
alt: node.attr("alt"),
|
12
|
+
summary: node.attr("summary"),
|
13
|
+
width: node.attr("width"))
|
14
14
|
end
|
15
15
|
|
16
16
|
def table(node)
|
@@ -31,8 +31,10 @@ module Asciidoctor
|
|
31
31
|
|
32
32
|
def colgroup(node, xml_table)
|
33
33
|
return if node.option? "autowidth"
|
34
|
+
|
34
35
|
cols = node&.attr("cols")&.split(/,/) or return
|
35
|
-
return unless cols.size > 1
|
36
|
+
return unless (cols.size > 1) && cols.all? { |c| /\d/.match(c) }
|
37
|
+
|
36
38
|
xml_table.colgroup do |cg|
|
37
39
|
node.columns.each do |col|
|
38
40
|
cg.col **{ width: "#{col.attr 'colpcwidth'}%" }
|
@@ -49,21 +51,21 @@ module Asciidoctor
|
|
49
51
|
end
|
50
52
|
|
51
53
|
def table_cell1(cell, thd)
|
52
|
-
if cell.style == :asciidoc
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
54
|
+
thd << if cell.style == :asciidoc
|
55
|
+
cell.content
|
56
|
+
else
|
57
|
+
cell.text
|
58
|
+
end
|
57
59
|
end
|
58
60
|
|
59
|
-
def table_cell(
|
61
|
+
def table_cell(node, xml_tr, tblsec)
|
60
62
|
cell_attributes =
|
61
|
-
{ id:
|
62
|
-
rowspan:
|
63
|
+
{ id: node.id, colspan: node.colspan, valign: node.attr("valign"),
|
64
|
+
rowspan: node.rowspan, align: node.attr("halign") }
|
63
65
|
cell_tag = "td"
|
64
|
-
cell_tag = "th" if tblsec == :head ||
|
66
|
+
cell_tag = "th" if tblsec == :head || node.style == :header
|
65
67
|
xml_tr.send cell_tag, **attr_code(cell_attributes) do |thd|
|
66
|
-
table_cell1(
|
68
|
+
table_cell1(node, thd)
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -77,7 +77,7 @@ module Asciidoctor
|
|
77
77
|
def term_def_parse(attrs, xml, node, _toplevel)
|
78
78
|
xml.terms **attr_code(attrs) do |section|
|
79
79
|
section.title { |t| t << node.title }
|
80
|
-
(s = node.attr("source")) && s.split(
|
80
|
+
(s = node.attr("source")) && s.split(",").each do |s1|
|
81
81
|
section.termdocsource(nil, **attr_code(bibitemid: s1))
|
82
82
|
end
|
83
83
|
section << node.content
|
@@ -131,6 +131,14 @@ module Asciidoctor
|
|
131
131
|
end
|
132
132
|
end.join("\n")
|
133
133
|
end
|
134
|
+
|
135
|
+
def termdefinition(node)
|
136
|
+
noko do |xml|
|
137
|
+
xml.definition do |d|
|
138
|
+
d << node.content
|
139
|
+
end
|
140
|
+
end.join("\n")
|
141
|
+
end
|
134
142
|
end
|
135
143
|
end
|
136
144
|
end
|
@@ -8,7 +8,7 @@ module Asciidoctor
|
|
8
8
|
module Standoc
|
9
9
|
module Validate
|
10
10
|
SOURCELOCALITY = "./termsource/origin//locality[@type = 'clause']/"\
|
11
|
-
|
11
|
+
"referenceFrom".freeze
|
12
12
|
|
13
13
|
def init_iev
|
14
14
|
return nil if @no_isobib
|
@@ -34,11 +34,14 @@ module Asciidoctor
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def content_validate(doc)
|
37
|
+
@fatalerror = []
|
38
|
+
xref_validate(doc)
|
37
39
|
section_validate(doc)
|
38
40
|
norm_ref_validate(doc)
|
39
41
|
repeat_id_validate(doc.root)
|
40
42
|
iev_validate(doc.root)
|
41
43
|
concept_validate(doc)
|
44
|
+
@fatalerror.empty? or clean_abort(@fatalerror.join("\n"), doc.to_xml)
|
42
45
|
end
|
43
46
|
|
44
47
|
def norm_ref_validate(doc)
|
@@ -51,8 +54,7 @@ module Asciidoctor
|
|
51
54
|
"Numeric reference in normative references")
|
52
55
|
found = true
|
53
56
|
end
|
54
|
-
found and
|
55
|
-
clean_abort("Numeric reference in normative references", doc.to_xml)
|
57
|
+
found and @fatalerror << "Numeric reference in normative references"
|
56
58
|
end
|
57
59
|
|
58
60
|
def concept_validate(doc)
|
@@ -62,19 +64,19 @@ module Asciidoctor
|
|
62
64
|
next if doc.at("//definitions//dt[@id = '#{x['target']}']")
|
63
65
|
|
64
66
|
ref = x&.at("../refterm")&.text
|
65
|
-
@log.add("Anchors", x,
|
67
|
+
@log.add("Anchors", x,
|
68
|
+
"Concept #{ref} is pointing to "\
|
66
69
|
"#{x['target']}, which is not a term or symbol")
|
67
70
|
found = true
|
68
71
|
end
|
69
|
-
found and
|
70
|
-
doc.to_xml)
|
72
|
+
found and @fatalerror << "Concept not cross-referencing term or symbol"
|
71
73
|
end
|
72
74
|
|
73
75
|
def repeat_id_validate1(ids, elem)
|
74
76
|
if ids[elem["id"]]
|
75
77
|
@log.add("Anchors", elem, "Anchor #{elem['id']} has already been "\
|
76
|
-
|
77
|
-
|
78
|
+
"used at line #{ids[elem['id']]}")
|
79
|
+
@fatalerror << "Multiple instances of same ID: #{elem['id']}"
|
78
80
|
else
|
79
81
|
ids[elem["id"]] = elem.line
|
80
82
|
end
|
@@ -83,12 +85,8 @@ module Asciidoctor
|
|
83
85
|
|
84
86
|
def repeat_id_validate(doc)
|
85
87
|
ids = {}
|
86
|
-
|
87
|
-
|
88
|
-
ids = repeat_id_validate1(ids, x)
|
89
|
-
end
|
90
|
-
rescue StandardError => e
|
91
|
-
clean_abort(e.message, doc.to_xml)
|
88
|
+
doc.xpath("//*[@id]").each do |x|
|
89
|
+
ids = repeat_id_validate1(ids, x)
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
@@ -130,6 +128,17 @@ module Asciidoctor
|
|
130
128
|
doc
|
131
129
|
end
|
132
130
|
|
131
|
+
# manually check for xref/@target, xref/@to integrity
|
132
|
+
def xref_validate(doc)
|
133
|
+
ids = doc.xpath("//*/@id").each_with_object({}) { |x, m| m[x.text] = 1 }
|
134
|
+
doc.xpath("//xref/@target | //xref/@to").each do |x|
|
135
|
+
next if ids[x.text]
|
136
|
+
|
137
|
+
@log.add("Anchors", x.parent,
|
138
|
+
"Crossreference target #{x.text} is undefined")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
133
142
|
def validate(doc)
|
134
143
|
content_validate(doc)
|
135
144
|
schema_validate(formattedstr_strip(doc.dup),
|
@@ -14,7 +14,8 @@ module Asciidoctor
|
|
14
14
|
callouts = x.elements.select { |e| e.name == "callout" }
|
15
15
|
annotations = x.elements.select { |e| e.name == "annotation" }
|
16
16
|
if callouts.size != annotations.size
|
17
|
-
|
17
|
+
@log.add("AsciiDoc Input", x,
|
18
|
+
"mismatch of callouts and annotations")
|
18
19
|
end
|
19
20
|
end
|
20
21
|
end
|
@@ -42,7 +43,9 @@ module Asciidoctor
|
|
42
43
|
root.xpath("//clause | //annex | //foreword | //introduction | "\
|
43
44
|
"//acknowledgements").each do |c|
|
44
45
|
next unless c.at("./clause")
|
45
|
-
next if c.elements.reject
|
46
|
+
next if c.elements.reject do |n|
|
47
|
+
%w(clause title).include? n.name
|
48
|
+
end.empty?
|
46
49
|
|
47
50
|
style_warning(c, "Hanging paragraph in clause")
|
48
51
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_dependency "latexmath"
|
39
39
|
spec.add_dependency "mathml2asciimath"
|
40
40
|
spec.add_dependency "metanorma-utils", "~> 1.2.0"
|
41
|
-
spec.add_dependency "relaton-cli", "~> 1.
|
41
|
+
spec.add_dependency "relaton-cli", "~> 1.9.0"
|
42
42
|
spec.add_dependency "relaton-iev", "~> 1.1.0"
|
43
43
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
44
44
|
|
@@ -6,39 +6,6 @@ RSpec.describe Asciidoctor::Standoc do
|
|
6
6
|
expect(Metanorma::Standoc::VERSION).not_to be nil
|
7
7
|
end
|
8
8
|
|
9
|
-
it "processes a blank document" do
|
10
|
-
input = <<~INPUT
|
11
|
-
#{ASCIIDOC_BLANK_HDR}
|
12
|
-
INPUT
|
13
|
-
output = <<~OUTPUT
|
14
|
-
#{BLANK_HDR}
|
15
|
-
<sections/>
|
16
|
-
</standard-document>
|
17
|
-
OUTPUT
|
18
|
-
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
19
|
-
.to be_equivalent_to xmlpp(output)
|
20
|
-
end
|
21
|
-
|
22
|
-
it "converts a blank document" do
|
23
|
-
FileUtils.rm_f "test.doc"
|
24
|
-
input = <<~INPUT
|
25
|
-
= Document title
|
26
|
-
Author
|
27
|
-
:docfile: test.adoc
|
28
|
-
:novalid:
|
29
|
-
INPUT
|
30
|
-
output = <<~OUTPUT
|
31
|
-
#{BLANK_HDR}
|
32
|
-
<sections/>
|
33
|
-
</standard-document>
|
34
|
-
OUTPUT
|
35
|
-
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
36
|
-
.to be_equivalent_to xmlpp(output)
|
37
|
-
expect(File.exist?("test.doc")).to be true
|
38
|
-
expect(File.exist?("test.pdf")).to be true
|
39
|
-
expect(File.exist?("htmlstyle.css")).to be false
|
40
|
-
end
|
41
|
-
|
42
9
|
it "assigns default scripts to major languages" do
|
43
10
|
FileUtils.rm_f "test.doc"
|
44
11
|
input = <<~INPUT
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
RSpec.describe Asciidoctor::Standoc do
|
5
|
+
it "processes a blank document" do
|
6
|
+
input = <<~INPUT
|
7
|
+
#{ASCIIDOC_BLANK_HDR}
|
8
|
+
INPUT
|
9
|
+
output = <<~OUTPUT
|
10
|
+
#{BLANK_HDR}
|
11
|
+
<sections/>
|
12
|
+
</standard-document>
|
13
|
+
OUTPUT
|
14
|
+
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
15
|
+
.to be_equivalent_to xmlpp(output)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "converts a blank document" do
|
19
|
+
FileUtils.rm_f "test.doc"
|
20
|
+
input = <<~INPUT
|
21
|
+
= Document title
|
22
|
+
Author
|
23
|
+
:docfile: test.adoc
|
24
|
+
:novalid:
|
25
|
+
INPUT
|
26
|
+
output = <<~OUTPUT
|
27
|
+
#{BLANK_HDR}
|
28
|
+
<sections/>
|
29
|
+
</standard-document>
|
30
|
+
OUTPUT
|
31
|
+
expect(xmlpp(Asciidoctor.convert(input, *OPTIONS)))
|
32
|
+
.to be_equivalent_to xmlpp(output)
|
33
|
+
expect(File.exist?("test.doc")).to be true
|
34
|
+
expect(File.exist?("test.pdf")).to be true
|
35
|
+
expect(File.exist?("htmlstyle.css")).to be false
|
36
|
+
end
|
37
|
+
end
|