metanorma-standoc 3.0.0 → 3.0.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.devel +1 -0
- data/lib/isodoc/html/htmlstyle.css +663 -408
- data/lib/isodoc/html/htmlstyle.scss +22 -19
- data/lib/metanorma/standoc/base.rb +8 -0
- data/lib/metanorma/standoc/basicdoc.rng +37 -32
- data/lib/metanorma/standoc/blocks.rb +3 -1
- data/lib/metanorma/standoc/blocks_notes.rb +4 -2
- data/lib/metanorma/standoc/cleanup_block.rb +3 -3
- data/lib/metanorma/standoc/cleanup_footnotes.rb +12 -0
- data/lib/metanorma/standoc/cleanup_maths.rb +6 -6
- data/lib/metanorma/standoc/cleanup_section_names.rb +1 -5
- data/lib/metanorma/standoc/front.rb +3 -3
- data/lib/metanorma/standoc/inline.rb +2 -2
- data/lib/metanorma/standoc/isodoc.rng +32 -17
- data/lib/metanorma/standoc/macros_note.rb +1 -0
- data/lib/metanorma/standoc/macros_plantuml.rb +10 -7
- data/lib/metanorma/standoc/utils.rb +9 -0
- data/lib/metanorma/standoc/validate.rb +2 -1
- data/lib/metanorma/standoc/validate_section.rb +2 -2
- data/lib/metanorma/standoc/validate_term.rb +33 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +4 -5
- metadata +27 -40
@@ -29,7 +29,7 @@ $docstage-colors-list: (
|
|
29
29
|
retired: #2E382E
|
30
30
|
);
|
31
31
|
|
32
|
-
@
|
32
|
+
@use 'base_style/all' as *;
|
33
33
|
|
34
34
|
/*
|
35
35
|
1. HTML & Body
|
@@ -92,24 +92,6 @@ nav {
|
|
92
92
|
@include sidebarNavToggle(white, #C70039)
|
93
93
|
}
|
94
94
|
|
95
|
-
@media screen and (min-width: 768px) {
|
96
|
-
.container {
|
97
|
-
padding-left: 360px;
|
98
|
-
}
|
99
|
-
|
100
|
-
.rule.toc {
|
101
|
-
display: none;
|
102
|
-
}
|
103
|
-
|
104
|
-
h1.toc-contents {
|
105
|
-
margin-top: 1em;
|
106
|
-
}
|
107
|
-
|
108
|
-
ul#toc-list, ul#toc-list > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
|
109
|
-
padding: 0;
|
110
|
-
margin: 0;
|
111
|
-
}
|
112
|
-
}
|
113
95
|
|
114
96
|
div.figure {
|
115
97
|
@include figureBlock();
|
@@ -643,6 +625,27 @@ To top button
|
|
643
625
|
margin: 2cm 1cm;
|
644
626
|
}
|
645
627
|
|
628
|
+
|
629
|
+
@media screen and (min-width: 768px) {
|
630
|
+
.container {
|
631
|
+
padding-left: 360px;
|
632
|
+
}
|
633
|
+
|
634
|
+
.rule.toc {
|
635
|
+
display: none;
|
636
|
+
}
|
637
|
+
|
638
|
+
h1.toc-contents {
|
639
|
+
margin-top: 1em;
|
640
|
+
}
|
641
|
+
|
642
|
+
ul#toc-list, ul#toc-list > :is(.h1, .h2, .h3, .h4, .h5, .h6) {
|
643
|
+
padding: 0;
|
644
|
+
margin: 0;
|
645
|
+
}
|
646
|
+
}
|
647
|
+
|
648
|
+
|
646
649
|
@media print {
|
647
650
|
.document-info, nav, .copyright {
|
648
651
|
page-break-before: always;
|
@@ -11,6 +11,14 @@ require_relative "localbib"
|
|
11
11
|
require_relative "init"
|
12
12
|
require "mn-requirements"
|
13
13
|
|
14
|
+
require 'set'
|
15
|
+
|
16
|
+
module Asciidoctor
|
17
|
+
module Compliance
|
18
|
+
ADMONITION_STYLES.add('EDITOR') unless ADMONITION_STYLES.include?('EDITOR')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
module Metanorma
|
15
23
|
module Standoc
|
16
24
|
module Base
|
@@ -599,17 +599,9 @@ It is included for convenience, in case processing the citation to extract the a
|
|
599
599
|
<a:documentation>The caption of the block</a:documentation>
|
600
600
|
</ref>
|
601
601
|
</optional>
|
602
|
-
<
|
603
|
-
<
|
604
|
-
|
605
|
-
<a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
|
606
|
-
(The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
|
607
|
-
</text>
|
608
|
-
<ref name="callout">
|
609
|
-
<a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
|
610
|
-
</ref>
|
611
|
-
</choice>
|
612
|
-
</oneOrMore>
|
602
|
+
<ref name="sourcecodebody">
|
603
|
+
<a:documentation>The sourcecode content</a:documentation>
|
604
|
+
</ref>
|
613
605
|
<zeroOrMore>
|
614
606
|
<ref name="annotation">
|
615
607
|
<a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
|
@@ -628,17 +620,9 @@ and is intended to be referenced by a callout within the source code</a:document
|
|
628
620
|
<a:documentation>The caption of the block</a:documentation>
|
629
621
|
</ref>
|
630
622
|
</optional>
|
631
|
-
<
|
632
|
-
<
|
633
|
-
|
634
|
-
<a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
|
635
|
-
(The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
|
636
|
-
</text>
|
637
|
-
<ref name="callout">
|
638
|
-
<a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
|
639
|
-
</ref>
|
640
|
-
</choice>
|
641
|
-
</oneOrMore>
|
623
|
+
<ref name="sourcecodebody">
|
624
|
+
<a:documentation>The sourcecode content</a:documentation>
|
625
|
+
</ref>
|
642
626
|
<zeroOrMore>
|
643
627
|
<ref name="annotation">
|
644
628
|
<a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
|
@@ -651,6 +635,20 @@ and is intended to be referenced by a callout within the source code</a:document
|
|
651
635
|
</ref>
|
652
636
|
</zeroOrMore>
|
653
637
|
</define>
|
638
|
+
<define name="sourcecodebody">
|
639
|
+
<a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
|
640
|
+
(The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
|
641
|
+
<element name="body">
|
642
|
+
<oneOrMore>
|
643
|
+
<choice>
|
644
|
+
<text/>
|
645
|
+
<ref name="callout">
|
646
|
+
<a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
|
647
|
+
</ref>
|
648
|
+
</choice>
|
649
|
+
</oneOrMore>
|
650
|
+
</element>
|
651
|
+
</define>
|
654
652
|
<define name="pre">
|
655
653
|
<a:documentation>Pre-formatted block. Wrapper for text to be rendered with fixed-width typeface, and preserving spaces including line breaks.
|
656
654
|
They are intended for a restricted number of functions, most typically ASCII Art (which is still in prominent use in some
|
@@ -1672,18 +1670,25 @@ which can be bookmarks as well as block or section references</a:documentation>
|
|
1672
1670
|
</optional>
|
1673
1671
|
</define>
|
1674
1672
|
<define name="XrefBody">
|
1675
|
-
<
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1673
|
+
<a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `<xx>my link text</xx>`)</a:documentation>
|
1674
|
+
<optional>
|
1675
|
+
<element name="display-text">
|
1676
|
+
<oneOrMore>
|
1677
|
+
<ref name="PureTextElement"/>
|
1678
|
+
</oneOrMore>
|
1679
|
+
</element>
|
1680
|
+
</optional>
|
1680
1681
|
</define>
|
1681
1682
|
<define name="ErefBody">
|
1682
|
-
<
|
1683
|
-
<
|
1684
|
-
<
|
1685
|
-
|
1686
|
-
|
1683
|
+
<optional>
|
1684
|
+
<element name="display-text">
|
1685
|
+
<oneOrMore>
|
1686
|
+
<ref name="PureTextElement">
|
1687
|
+
<a:documentation>The textual content of the element. The `text` is what we wish to show the link as (e.g., the "content" of `<xx>my link text</xx>`)</a:documentation>
|
1688
|
+
</ref>
|
1689
|
+
</oneOrMore>
|
1690
|
+
</element>
|
1691
|
+
</optional>
|
1687
1692
|
</define>
|
1688
1693
|
<define name="fn">
|
1689
1694
|
<a:documentation>Inline reference to a paragraph or paragraphs, appearing as a footnote.
|
@@ -201,7 +201,9 @@ module Metanorma
|
|
201
201
|
fragment = ::Nokogiri::XML::Builder.new do |xml|
|
202
202
|
xml.sourcecode **listing_attrs(node) do |s|
|
203
203
|
figure_title(node, s)
|
204
|
-
s
|
204
|
+
s.body do |b|
|
205
|
+
b << node.content
|
206
|
+
end
|
205
207
|
end
|
206
208
|
end
|
207
209
|
fragment.to_xml(encoding: "US-ASCII", save_with:
|
@@ -90,8 +90,10 @@ module Metanorma
|
|
90
90
|
end
|
91
91
|
|
92
92
|
def admonition_name(node)
|
93
|
-
ret = node.attr("type") || node.attr("name")
|
94
|
-
ret
|
93
|
+
ret = node.attr("type") || node.attr("name") or return
|
94
|
+
ret = ret.downcase
|
95
|
+
ret == "editor" and ret = "editorial"
|
96
|
+
ret
|
95
97
|
end
|
96
98
|
|
97
99
|
def admonition(node)
|
@@ -119,8 +119,8 @@ module Metanorma
|
|
119
119
|
|
120
120
|
def align_callouts_to_annotations(xmldoc)
|
121
121
|
xmldoc.xpath("//sourcecode").each do |x|
|
122
|
-
callouts = x.
|
123
|
-
annotations = x.
|
122
|
+
callouts = x.xpath("./body/callout")
|
123
|
+
annotations = x.xpath("./annotation")
|
124
124
|
callouts.size == annotations.size and
|
125
125
|
link_callouts_to_annotations(callouts, annotations)
|
126
126
|
end
|
@@ -163,7 +163,7 @@ module Metanorma
|
|
163
163
|
acc << safe_noko(a[0], node.document)
|
164
164
|
a.size == 4 or next
|
165
165
|
acc << Asciidoctor.convert(
|
166
|
-
a[2], doctype: :inline, backend:
|
166
|
+
a[2], doctype: :inline, backend: backend&.to_sym || :standoc
|
167
167
|
)
|
168
168
|
end.join
|
169
169
|
end
|
@@ -118,9 +118,21 @@ module Metanorma
|
|
118
118
|
fnote.children = "[ERROR]"
|
119
119
|
end
|
120
120
|
|
121
|
+
def process_hidden_footnotes(xmldoc)
|
122
|
+
xmldoc.xpath("//fn").each do |fn|
|
123
|
+
first_text = fn.xpath(".//text()")
|
124
|
+
.find { |node| !node.text.strip.empty? } or return
|
125
|
+
if first_text.text.strip.start_with?("hiddenref%")
|
126
|
+
first_text.content = first_text.text.sub(/^hiddenref%/, "")
|
127
|
+
fn["hiddenref"] = true
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
121
132
|
def footnote_cleanup(xmldoc)
|
122
133
|
footnote_block_cleanup(xmldoc)
|
123
134
|
title_footnote_move(xmldoc)
|
135
|
+
process_hidden_footnotes(xmldoc)
|
124
136
|
table_footnote_renumber(xmldoc)
|
125
137
|
other_footnote_renumber(xmldoc)
|
126
138
|
xmldoc.xpath("//fn").each do |fn|
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "asciimath2unitsml"
|
2
1
|
require_relative "cleanup_mathvariant"
|
3
2
|
|
4
3
|
module Metanorma
|
@@ -39,9 +38,12 @@ module Metanorma
|
|
39
38
|
<math xmlns='#{MATHML_NS}'><mstyle displaystyle='false'><mn>#{expr}</mn></mstyle></math>
|
40
39
|
MATH
|
41
40
|
else
|
41
|
+
unitsml = if expr.include?("unitsml")
|
42
|
+
{ unitsml: { xml: true,
|
43
|
+
multiplier: :space } }
|
44
|
+
else {} end
|
42
45
|
Plurimath::Math.parse(expr, "asciimath")
|
43
|
-
.to_mathml(display_style: elem["block"]
|
44
|
-
unitsml_xml: expr.include?("unitsml"))
|
46
|
+
.to_mathml(**{ display_style: elem["block"] }.merge(unitsml))
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
@@ -115,7 +117,7 @@ module Metanorma
|
|
115
117
|
def gather_unitsml(unitsml, xmldoc, tag)
|
116
118
|
tags = xmldoc.xpath(".//m:#{tag}", "m" => UNITSML_NS)
|
117
119
|
.each_with_object({}) do |x, m|
|
118
|
-
m[x["
|
120
|
+
m[x["id"]] = x.remove
|
119
121
|
end
|
120
122
|
tags.empty? and return
|
121
123
|
set = unitsml.add_child("<#{tag}Set/>").first
|
@@ -180,11 +182,9 @@ module Metanorma
|
|
180
182
|
end
|
181
183
|
|
182
184
|
def mathml_cleanup(xmldoc)
|
183
|
-
a2u = Asciimath2UnitsML::Conv.new(asciimath2unitsml_options)
|
184
185
|
xmldoc.xpath("//stem[@type = 'MathML'][not(@validate = 'false')]")
|
185
186
|
.each do |x|
|
186
187
|
mathml_xml_cleanup(x)
|
187
|
-
a2u.MathML2UnitsML(x)
|
188
188
|
mathml_mathvariant(x)
|
189
189
|
end
|
190
190
|
xmldoc.xpath("//stem[@type = 'MathML']")
|
@@ -144,12 +144,8 @@ module Metanorma
|
|
144
144
|
sym and m[sym] += 1
|
145
145
|
end
|
146
146
|
|
147
|
-
SECTION_CONTAINERS = %w(foreword introduction acknowledgements abstract
|
148
|
-
clause clause references terms definitions annex
|
149
|
-
appendix).freeze
|
150
|
-
|
151
147
|
def sections_variant_title_cleanup(xml)
|
152
|
-
path =
|
148
|
+
path = section_containers.map { |x| "./ancestor::#{x}" }.join(" | ")
|
153
149
|
xml.xpath("//p[@variant_title]").each do |p|
|
154
150
|
p.name = "variant-title"
|
155
151
|
p.delete("id")
|
@@ -217,9 +217,9 @@ module Metanorma
|
|
217
217
|
["en"].each do |lang|
|
218
218
|
at = { language: lang, format: "text/plain" }
|
219
219
|
xml.title **attr_code(at) do |t|
|
220
|
-
title = Metanorma::Utils::asciidoc_sub(
|
221
|
-
|
222
|
-
t <<
|
220
|
+
title = Metanorma::Utils::asciidoc_sub(
|
221
|
+
node.attr("title") || node.attr("title-en") || node.attr("doctitle"))
|
222
|
+
t << title
|
223
223
|
end
|
224
224
|
end
|
225
225
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
require "unicode2latex"
|
2
1
|
require "mime/types"
|
3
2
|
require "base64"
|
4
3
|
require "English"
|
@@ -27,7 +26,8 @@ module Metanorma
|
|
27
26
|
end
|
28
27
|
|
29
28
|
def latex_parse1(text, block)
|
30
|
-
lxm_input = Unicode2LaTeX.unicode2latex(@c.decode(text))
|
29
|
+
#lxm_input = Unicode2LaTeX.unicode2latex(@c.decode(text))
|
30
|
+
lxm_input = @c.decode(text)
|
31
31
|
results = Plurimath::Math.parse(lxm_input, "latex")
|
32
32
|
.to_mathml(display_style: block)
|
33
33
|
if results.nil?
|
@@ -33,6 +33,15 @@
|
|
33
33
|
</zeroOrMore>
|
34
34
|
</element>
|
35
35
|
</define>
|
36
|
+
<define name="fn" combine="interleave">
|
37
|
+
<optional>
|
38
|
+
<attribute name="hiddenref">
|
39
|
+
<a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
|
40
|
+
This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
|
41
|
+
<data type="boolean"/>
|
42
|
+
</attribute>
|
43
|
+
</optional>
|
44
|
+
</define>
|
36
45
|
<define name="index-primary">
|
37
46
|
<element name="primary">
|
38
47
|
<oneOrMore>
|
@@ -245,23 +254,9 @@
|
|
245
254
|
<a:documentation>The caption of the block</a:documentation>
|
246
255
|
</ref>
|
247
256
|
</optional>
|
248
|
-
<
|
249
|
-
<
|
250
|
-
|
251
|
-
<a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
|
252
|
-
(The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
|
253
|
-
</text>
|
254
|
-
<ref name="callout">
|
255
|
-
<a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
|
256
|
-
</ref>
|
257
|
-
<ref name="xref">
|
258
|
-
<a:documentation>Hyperlink of code segment to another part of the document</a:documentation>
|
259
|
-
</ref>
|
260
|
-
<ref name="eref">
|
261
|
-
<a:documentation>Hyperlink of code segment to external bibliographic resource</a:documentation>
|
262
|
-
</ref>
|
263
|
-
</choice>
|
264
|
-
</oneOrMore>
|
257
|
+
<ref name="sourcecodebody">
|
258
|
+
<a:documentation>The sourcecode content</a:documentation>
|
259
|
+
</ref>
|
265
260
|
<zeroOrMore>
|
266
261
|
<ref name="annotation">
|
267
262
|
<a:documentation>Annotations to the source code; each annotation consists of zero or more paragraphs,
|
@@ -277,6 +272,26 @@ and is intended to be referenced by a callout within the source code</a:document
|
|
277
272
|
<a:documentation>A source for the block</a:documentation>
|
278
273
|
</ref>
|
279
274
|
</define>
|
275
|
+
<define name="sourcecodebody">
|
276
|
+
<a:documentation>The computer code or other such text presented in the block, as a single unformatted string.
|
277
|
+
(The string should be treated as pre-formatted text, with whitespace treated as significant)</a:documentation>
|
278
|
+
<element name="body">
|
279
|
+
<oneOrMore>
|
280
|
+
<choice>
|
281
|
+
<text/>
|
282
|
+
<ref name="callout">
|
283
|
+
<a:documentation>Zero or more cross-references; these are intended to be embedded within the content string, and link to annotations</a:documentation>
|
284
|
+
</ref>
|
285
|
+
<ref name="xref">
|
286
|
+
<a:documentation>Hyperlink of code segment to another part of the document</a:documentation>
|
287
|
+
</ref>
|
288
|
+
<ref name="eref">
|
289
|
+
<a:documentation>Hyperlink of code segment to external bibliographic resource</a:documentation>
|
290
|
+
</ref>
|
291
|
+
</choice>
|
292
|
+
</oneOrMore>
|
293
|
+
</element>
|
294
|
+
</define>
|
280
295
|
<define name="sections">
|
281
296
|
<element name="sections">
|
282
297
|
<oneOrMore>
|
@@ -34,24 +34,27 @@ module Metanorma
|
|
34
34
|
# Windows Ruby 2.4 will crash if a Tempfile is "mv"ed.
|
35
35
|
# This is why we need to copy and then unlink.
|
36
36
|
def self.generate_file(parent, reader)
|
37
|
-
|
37
|
+
ldir = localdir(parent)
|
38
38
|
imagesdir = parent.document.attr("imagesdir")
|
39
|
-
umlfile, outfile = save_plantuml parent, reader,
|
39
|
+
umlfile, outfile = save_plantuml parent, reader, ldir
|
40
40
|
run(umlfile, outfile) or
|
41
41
|
raise "No image output from PlantUML (#{umlfile}, #{outfile})!"
|
42
42
|
umlfile.unlink
|
43
|
-
|
44
|
-
path = path_prep(localdir, imagesdir)
|
43
|
+
path = path_prep(ldir, imagesdir)
|
45
44
|
filename = File.basename(outfile.to_s)
|
46
45
|
FileUtils.cp(outfile, path) and outfile.unlink
|
47
|
-
|
48
46
|
imagesdir ? filename : File.join(path, filename)
|
49
47
|
end
|
50
48
|
|
49
|
+
def self.localdir(parent)
|
50
|
+
ret = Metanorma::Utils::localdir(parent.document)
|
51
|
+
File.writable?(ret) or
|
52
|
+
raise "Destination directory #{ret} not writable for PlantUML!"
|
53
|
+
ret
|
54
|
+
end
|
55
|
+
|
51
56
|
def self.path_prep(localdir, imagesdir)
|
52
57
|
path = Pathname.new(localdir) + (imagesdir || "plantuml")
|
53
|
-
File.writable?(localdir) or
|
54
|
-
raise "Destination path #{path} not writable for PlantUML!"
|
55
58
|
path.mkpath
|
56
59
|
File.writable?(path) or
|
57
60
|
raise "Destination path #{path} not writable for PlantUML!"
|
@@ -108,6 +108,15 @@ module Metanorma
|
|
108
108
|
.gsub("'", "'")
|
109
109
|
end
|
110
110
|
|
111
|
+
SECTION_CONTAINERS =
|
112
|
+
%w(foreword introduction acknowledgements abstract
|
113
|
+
clause references terms definitions annex appendix indexsect
|
114
|
+
executivesummary).freeze
|
115
|
+
|
116
|
+
def section_containers
|
117
|
+
SECTION_CONTAINERS
|
118
|
+
end
|
119
|
+
|
111
120
|
# wrapped in <sections>
|
112
121
|
def adoc2xml(text, flavour)
|
113
122
|
Nokogiri::XML(text).root and return text
|
@@ -21,13 +21,14 @@ module Metanorma
|
|
21
21
|
concept_validate(doc, "concept", "refterm")
|
22
22
|
concept_validate(doc, "related", "preferred//name")
|
23
23
|
preferred_validate(doc)
|
24
|
+
termsect_validate(doc)
|
24
25
|
table_validate(doc)
|
25
26
|
requirement_validate(doc)
|
26
27
|
image_validate(doc)
|
27
28
|
math_validate(doc)
|
28
29
|
fatalerrors = @log.abort_messages
|
29
30
|
fatalerrors.empty? or
|
30
|
-
clean_abort(fatalerrors.join("\n"), doc)
|
31
|
+
clean_abort("\n\nFATAL ERRROS:\n\n#{fatalerrors.join("\n\n")}", doc)
|
31
32
|
end
|
32
33
|
|
33
34
|
MATHML_NS = "http://www.w3.org/1998/Math/MathML".freeze
|
@@ -11,8 +11,8 @@ module Metanorma
|
|
11
11
|
|
12
12
|
def sourcecode_style(root)
|
13
13
|
root.xpath("//sourcecode").each do |x|
|
14
|
-
callouts = x.
|
15
|
-
annotations = x.
|
14
|
+
callouts = x.xpath("./body/callout")
|
15
|
+
annotations = x.xpath("./annotation")
|
16
16
|
callouts_error(x, callouts, annotations)
|
17
17
|
end
|
18
18
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "iev"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
module Standoc
|
3
5
|
module Validate
|
@@ -7,7 +9,7 @@ module Metanorma
|
|
7
9
|
def init_iev
|
8
10
|
@no_isobib and return nil
|
9
11
|
@iev and return @iev
|
10
|
-
@iev = Iev::Db.new(@iev_globalname, @iev_localname) unless @no_isobib
|
12
|
+
@iev = ::Iev::Db.new(@iev_globalname, @iev_localname) unless @no_isobib
|
11
13
|
@iev
|
12
14
|
end
|
13
15
|
|
@@ -82,6 +84,36 @@ module Metanorma
|
|
82
84
|
@log.add("Terms", v.first, err, severity: 1)
|
83
85
|
end
|
84
86
|
end
|
87
|
+
|
88
|
+
def find_illegal_designations(xmldoc)
|
89
|
+
xmldoc.xpath("//preferred | //admitted | //deprecates")
|
90
|
+
.each_with_object({}) do |d, m|
|
91
|
+
d.ancestors.detect { |x| x.name == "terms" } and next
|
92
|
+
c = d.ancestors.detect do |x|
|
93
|
+
section_containers.include?(x.name)
|
94
|
+
end
|
95
|
+
c["id"] ||= "_#{UUIDTools::UUID.random_create}"
|
96
|
+
m[c["id"]] ||= { clause: c, designations: [] }
|
97
|
+
m[c["id"]][:designations] << d
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def termsect_validate(xmldoc)
|
102
|
+
errors = find_illegal_designations(xmldoc)
|
103
|
+
errors.each_value do |v|
|
104
|
+
desgns = v[:designations].map do |x|
|
105
|
+
@c.encode(x.text.strip, :basic, :hexadecimal)
|
106
|
+
end.join(", ")
|
107
|
+
err = <<~ERROR
|
108
|
+
Clause not recognised as a term clause, but contains designation markup
|
109
|
+
(preferred:[], admitted:[], alt:[], deprecated:[]):<br/>
|
110
|
+
#{desgns}</br>
|
111
|
+
Ensure the parent clause is recognised as a terms clause by inserting <code>[heading=terms and definitions]</code> above the title,
|
112
|
+
in case the heading is not automatically recognised. See also <a href="https://www.metanorma.org/author/topics/sections/concepts/#clause-title">Metanorma documentation</a>.
|
113
|
+
ERROR
|
114
|
+
@log.add("Terms", v[:clause], err, severity: 0)
|
115
|
+
end
|
116
|
+
end
|
85
117
|
end
|
86
118
|
end
|
87
119
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "crass", "~> 1.0.0"
|
34
34
|
spec.add_dependency "iev", "~> 0.3.5"
|
35
|
-
spec.add_dependency "isodoc", "~> 3.
|
35
|
+
spec.add_dependency "isodoc", "~> 3.1.0"
|
36
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
|
38
38
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.0"
|
@@ -40,12 +40,10 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_dependency "metanorma-utils", "~> 1.10.0"
|
41
41
|
spec.add_dependency "ruby-jing"
|
42
42
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
43
|
-
spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
|
44
43
|
spec.add_dependency "concurrent-ruby"
|
45
44
|
spec.add_dependency "pngcheck"
|
46
45
|
spec.add_dependency "relaton-cli", "~> 1.20.0"
|
47
46
|
spec.add_dependency "relaton-iev", "~> 1.2.0"
|
48
|
-
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
49
47
|
|
50
48
|
spec.add_development_dependency "debug"
|
51
49
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
@@ -53,8 +51,9 @@ Gem::Specification.new do |spec|
|
|
53
51
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
54
52
|
spec.add_development_dependency "rake", "~> 13.0"
|
55
53
|
spec.add_development_dependency "rspec", "~> 3.6"
|
56
|
-
spec.add_development_dependency "rubocop", "~> 1
|
57
|
-
spec.add_development_dependency "
|
54
|
+
spec.add_development_dependency "rubocop", "~> 1"
|
55
|
+
spec.add_development_dependency "rubocop-performance"
|
56
|
+
spec.add_development_dependency "sassc-embedded", "~> 1"
|
58
57
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
59
58
|
spec.add_development_dependency "timecop", "~> 0.9"
|
60
59
|
spec.add_development_dependency "vcr", "~> 6.1.0"
|