metanorma-standoc 3.0.2 → 3.0.4
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/isodoc/html/htmlstyle.css +7 -0
- data/lib/metanorma/standoc/basicdoc.rng +34 -27
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_block.rb +1 -1
- data/lib/metanorma/standoc/cleanup_footnotes.rb +12 -0
- data/lib/metanorma/standoc/cleanup_inline.rb +4 -6
- data/lib/metanorma/standoc/cleanup_maths.rb +6 -6
- data/lib/metanorma/standoc/cleanup_section.rb +16 -22
- data/lib/metanorma/standoc/cleanup_section_names.rb +26 -5
- data/lib/metanorma/standoc/cleanup_table.rb +22 -0
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/inline.rb +2 -2
- data/lib/metanorma/standoc/isodoc.rng +37 -1
- data/lib/metanorma/standoc/macros_inline.rb +24 -0
- data/lib/metanorma/standoc/macros_plantuml.rb +10 -7
- data/lib/metanorma/standoc/section.rb +1 -1
- data/lib/metanorma/standoc/utils.rb +9 -0
- data/lib/metanorma/standoc/validate.rb +2 -1
- data/lib/metanorma/standoc/validate_term.rb +33 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +4 -5
- metadata +22 -36
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 86e5f93e957beab663c8b30d6ea82cc211b158a6bf8b9f0e49a9843c21e910d2
|
4
|
+
data.tar.gz: 3b98332cd095ac90319145032f637b3fc1388ddc0f5ccbb6b1599d0b331cdd35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e8aa9bd17082e4e9a06f26635282cb4eb3088ecf636c7144299b57d547cfb2ef2913f286bf67aa40557670b46abd0625d9545f9a8812b77cb597c2e00ef3af4
|
7
|
+
data.tar.gz: ec6148203ca15276fe22bcad392a30e1adb581791f6c4577f20fffaa401998f46384b0f374625dc34c40cc02f53695777eb974b1f678c942598d4efdafaf7885
|
@@ -382,33 +382,7 @@ in a document (e.g. sourcecode annotations)</a:documentation>
|
|
382
382
|
<a:documentation>Block intended to capture reviewer comments about some text in the document</a:documentation>
|
383
383
|
<element name="review">
|
384
384
|
<ref name="RequiredId"/>
|
385
|
-
<
|
386
|
-
<a:documentation>The party who has offered the comment</a:documentation>
|
387
|
-
</attribute>
|
388
|
-
<optional>
|
389
|
-
<attribute name="type">
|
390
|
-
<a:documentation>The type of reviewer comment</a:documentation>
|
391
|
-
</attribute>
|
392
|
-
</optional>
|
393
|
-
<optional>
|
394
|
-
<attribute name="date">
|
395
|
-
<a:documentation>The date when the comment was made</a:documentation>
|
396
|
-
<data type="dateTime"/>
|
397
|
-
</attribute>
|
398
|
-
</optional>
|
399
|
-
<optional>
|
400
|
-
<attribute name="from">
|
401
|
-
<a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
|
402
|
-
If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
|
403
|
-
<data type="IDREF"/>
|
404
|
-
</attribute>
|
405
|
-
</optional>
|
406
|
-
<optional>
|
407
|
-
<attribute name="to">
|
408
|
-
<a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
|
409
|
-
<data type="IDREF"/>
|
410
|
-
</attribute>
|
411
|
-
</optional>
|
385
|
+
<ref name="ReviewAttributes"/>
|
412
386
|
<oneOrMore>
|
413
387
|
<ref name="paragraph">
|
414
388
|
<a:documentation>Reviewer comments content</a:documentation>
|
@@ -416,6 +390,35 @@ If not provided, the comment applies in the vicinity of the place it has been in
|
|
416
390
|
</oneOrMore>
|
417
391
|
</element>
|
418
392
|
</define>
|
393
|
+
<define name="ReviewAttributes">
|
394
|
+
<attribute name="reviewer">
|
395
|
+
<a:documentation>The party who has offered the comment</a:documentation>
|
396
|
+
</attribute>
|
397
|
+
<optional>
|
398
|
+
<attribute name="type">
|
399
|
+
<a:documentation>The type of reviewer comment</a:documentation>
|
400
|
+
</attribute>
|
401
|
+
</optional>
|
402
|
+
<optional>
|
403
|
+
<attribute name="date">
|
404
|
+
<a:documentation>The date when the comment was made</a:documentation>
|
405
|
+
<data type="dateTime"/>
|
406
|
+
</attribute>
|
407
|
+
</optional>
|
408
|
+
<optional>
|
409
|
+
<attribute name="from">
|
410
|
+
<a:documentation>Identifier for the start of the text or point in the text to which the comment applies.
|
411
|
+
If not provided, the comment applies in the vicinity of the place it has been inserted into the text</a:documentation>
|
412
|
+
<data type="IDREF"/>
|
413
|
+
</attribute>
|
414
|
+
</optional>
|
415
|
+
<optional>
|
416
|
+
<attribute name="to">
|
417
|
+
<a:documentation>Identifier for the end of the text to which the comment applies</a:documentation>
|
418
|
+
<data type="IDREF"/>
|
419
|
+
</attribute>
|
420
|
+
</optional>
|
421
|
+
</define>
|
419
422
|
<define name="NumberingAttributes">
|
420
423
|
<optional>
|
421
424
|
<attribute name="unnumbered">
|
@@ -857,6 +860,7 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
|
|
857
860
|
<define name="tr">
|
858
861
|
<a:documentation>Sequence of cells to be displayed as a row in a table</a:documentation>
|
859
862
|
<element name="tr">
|
863
|
+
<ref name="TrAttributes"/>
|
860
864
|
<oneOrMore>
|
861
865
|
<choice>
|
862
866
|
<ref name="td">
|
@@ -869,6 +873,9 @@ in case the table cannot be rendered accessibly (HTML 5)</a:documentation>
|
|
869
873
|
</oneOrMore>
|
870
874
|
</element>
|
871
875
|
</define>
|
876
|
+
<define name="TrAttributes">
|
877
|
+
<empty/>
|
878
|
+
</define>
|
872
879
|
<define name="tr-no-id">
|
873
880
|
<a:documentation>Sequence of cells to be displayed as a row in a table: optional ID attributes recursively (for use in Relaton, metadata)</a:documentation>
|
874
881
|
<element name="tr">
|
@@ -82,6 +82,7 @@ module Metanorma
|
|
82
82
|
boilerplate_cleanup(xmldoc) # feeds: xref_cleanup for new <<>> introduced
|
83
83
|
xref_cleanup(xmldoc)
|
84
84
|
svgmap_cleanup(xmldoc) # feeds: img_cleanup
|
85
|
+
review_cleanup(xmldoc)
|
85
86
|
toc_cleanup(xmldoc)
|
86
87
|
smartquotes_cleanup(xmldoc)
|
87
88
|
linebreak_cleanup(xmldoc)
|
@@ -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|
|
@@ -145,10 +145,9 @@ module Metanorma
|
|
145
145
|
elem.xpath(IDREF).each do |s|
|
146
146
|
if (ret = Metanorma::Utils::to_ncname(s.value)) != (orig = s.value)
|
147
147
|
s.value = ret
|
148
|
-
output = s.parent.dup
|
149
|
-
output.children.remove
|
150
148
|
@log.add("Anchors", s.parent,
|
151
|
-
"normalised identifier
|
149
|
+
"normalised identifier to #{ret} from #{orig}",
|
150
|
+
display: false)
|
152
151
|
end
|
153
152
|
end
|
154
153
|
end
|
@@ -157,10 +156,9 @@ module Metanorma
|
|
157
156
|
elem.xpath("//xref/@target").each do |s|
|
158
157
|
if (ret = to_xreftarget(s.value)) != (orig = s.value)
|
159
158
|
s.value = ret
|
160
|
-
output = s.parent.dup
|
161
|
-
output.children.remove
|
162
159
|
@log.add("Anchors", s.parent,
|
163
|
-
"normalised identifier
|
160
|
+
"normalised identifier to #{ret} from #{orig}",
|
161
|
+
display: false)
|
164
162
|
end
|
165
163
|
end
|
166
164
|
end
|
@@ -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']")
|
@@ -192,7 +192,7 @@ module Metanorma
|
|
192
192
|
xmldoc.at("//sections") or return
|
193
193
|
ins = insert_before(xmldoc, "//sections")
|
194
194
|
xmldoc.xpath("//sections//*[@beforeclauses = 'true']")
|
195
|
-
.
|
195
|
+
.reverse_each do |x|
|
196
196
|
x.delete("beforeclauses")
|
197
197
|
ins.previous = x.remove
|
198
198
|
end
|
@@ -201,7 +201,7 @@ module Metanorma
|
|
201
201
|
|
202
202
|
# only move clausebefore notes at the very end of preface
|
203
203
|
def endofpreface_clausebefore(xml, ins)
|
204
|
-
xml.xpath("//preface//*[@beforeclauses = 'true']").
|
204
|
+
xml.xpath("//preface//*[@beforeclauses = 'true']").reverse_each do |x|
|
205
205
|
textafter = xml.xpath("//preface//*") & x.xpath("./following::*")
|
206
206
|
textafter.text.strip.empty? or break
|
207
207
|
x.delete("beforeclauses")
|
@@ -217,29 +217,23 @@ module Metanorma
|
|
217
217
|
ins
|
218
218
|
end
|
219
219
|
|
220
|
-
def
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
found = false
|
228
|
-
xmldoc.xpath("//floating-title").each do |t|
|
229
|
-
t.next_element.nil? or next
|
230
|
-
%w(sections annex preface).include? t.parent.name and next
|
231
|
-
t.parent.next = t
|
232
|
-
found = true
|
233
|
-
end
|
234
|
-
break unless found
|
220
|
+
def review_cleanup(xmldoc)
|
221
|
+
reviews = xmldoc.xpath("//review")
|
222
|
+
reviews.empty? and return
|
223
|
+
ctr = xmldoc.root.add_child("<review-container/>").first
|
224
|
+
reviews.each do |r|
|
225
|
+
review_set_location(r)
|
226
|
+
ctr << r
|
235
227
|
end
|
236
228
|
end
|
237
229
|
|
238
|
-
def
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
230
|
+
def review_set_location(review)
|
231
|
+
unless review["from"]
|
232
|
+
id = "_#{UUIDTools::UUID.random_create}"
|
233
|
+
review.previous = "<bookmark id='#{id}'/>"
|
234
|
+
review["from"] = id
|
235
|
+
end
|
236
|
+
review["to"] ||= review["from"]
|
243
237
|
end
|
244
238
|
end
|
245
239
|
end
|
@@ -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")
|
@@ -160,6 +156,31 @@ module Metanorma
|
|
160
156
|
end
|
161
157
|
end
|
162
158
|
end
|
159
|
+
|
160
|
+
def floatingtitle_cleanup(xmldoc)
|
161
|
+
pop_floating_title(xmldoc) # done again, after endofpreface_clausebefore
|
162
|
+
floating_title_preface2sections(xmldoc)
|
163
|
+
end
|
164
|
+
|
165
|
+
def pop_floating_title(xmldoc)
|
166
|
+
loop do
|
167
|
+
found = false
|
168
|
+
xmldoc.xpath("//floating-title").each do |t|
|
169
|
+
t.next_element.nil? or next
|
170
|
+
%w(sections annex preface).include? t.parent.name and next
|
171
|
+
t.parent.next = t
|
172
|
+
found = true
|
173
|
+
end
|
174
|
+
break unless found
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def floating_title_preface2sections(xmldoc)
|
179
|
+
t = xmldoc.at("//preface/floating-title") or return
|
180
|
+
s = xmldoc.at("//sections")
|
181
|
+
t.next_element or
|
182
|
+
s.children.first.previous = t.remove
|
183
|
+
end
|
163
184
|
end
|
164
185
|
end
|
165
186
|
end
|
@@ -47,6 +47,8 @@ module Metanorma
|
|
47
47
|
sources_table_cleanup(xmldoc)
|
48
48
|
notes_table_cleanup(xmldoc)
|
49
49
|
header_rows_cleanup(xmldoc)
|
50
|
+
tr_style_cleanup(xmldoc)
|
51
|
+
td_style_cleanup(xmldoc)
|
50
52
|
end
|
51
53
|
|
52
54
|
def sources_table_cleanup(xmldoc)
|
@@ -75,6 +77,26 @@ module Metanorma
|
|
75
77
|
end
|
76
78
|
end
|
77
79
|
end
|
80
|
+
|
81
|
+
def tr_style_cleanup(xmldoc)
|
82
|
+
xmldoc.xpath("//tr[.//tr-style]").each do |tr|
|
83
|
+
ret = tr.xpath(".//tr-style").each_with_object([]) do |s, m|
|
84
|
+
m << s.text
|
85
|
+
end
|
86
|
+
tr["style"] = ret.join(";")
|
87
|
+
end
|
88
|
+
xmldoc.xpath(".//tr-style").each(&:remove)
|
89
|
+
end
|
90
|
+
|
91
|
+
def td_style_cleanup(xmldoc)
|
92
|
+
xmldoc.xpath("//td[.//td-style] | //th[.//td-style]").each do |tr|
|
93
|
+
ret = tr.xpath(".//td-style").each_with_object([]) do |s, m|
|
94
|
+
m << s.text
|
95
|
+
end
|
96
|
+
tr["style"] = ret.join(";")
|
97
|
+
end
|
98
|
+
xmldoc.xpath(".//td-style").each(&:remove)
|
99
|
+
end
|
78
100
|
end
|
79
101
|
end
|
80
102
|
end
|
@@ -71,6 +71,8 @@ module Metanorma
|
|
71
71
|
inline_macro Metanorma::Standoc::PassInlineMacro
|
72
72
|
inline_macro Metanorma::Standoc::StdLinkInlineMacro
|
73
73
|
inline_macro Metanorma::Standoc::NumberInlineMacro
|
74
|
+
inline_macro Metanorma::Standoc::TrStyleInlineMacro
|
75
|
+
inline_macro Metanorma::Standoc::TdStyleInlineMacro
|
74
76
|
block Metanorma::Standoc::ToDoAdmonitionBlock
|
75
77
|
block Metanorma::Standoc::EditorAdmonitionBlock
|
76
78
|
treeprocessor Metanorma::Standoc::EditorInlineAdmonitionBlock
|
@@ -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?
|
@@ -17,7 +17,7 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v2.0.
|
20
|
+
<!-- VERSION v2.0.2 -->
|
21
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">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
@@ -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>
|
@@ -414,6 +423,21 @@ normative or informative references, some split references into sections organiz
|
|
414
423
|
</oneOrMore>
|
415
424
|
</choice>
|
416
425
|
</define>
|
426
|
+
<define name="TdAttributes" combine="interleave">
|
427
|
+
<attribute name="style">
|
428
|
+
<a:documentation>CSS style: only background-color supported</a:documentation>
|
429
|
+
</attribute>
|
430
|
+
</define>
|
431
|
+
<define name="ThAttributes" combine="interleave">
|
432
|
+
<attribute name="style">
|
433
|
+
<a:documentation>CSS style: only background-color supported</a:documentation>
|
434
|
+
</attribute>
|
435
|
+
</define>
|
436
|
+
<define name="TrAttributes">
|
437
|
+
<attribute name="style">
|
438
|
+
<a:documentation>CSS style: only background-color supported</a:documentation>
|
439
|
+
</attribute>
|
440
|
+
</define>
|
417
441
|
<define name="table-note">
|
418
442
|
<element name="note">
|
419
443
|
<ref name="OptionalId"/>
|
@@ -1263,6 +1287,11 @@ numbers</a:documentation>
|
|
1263
1287
|
<a:documentation>Colophon or postface material</a:documentation>
|
1264
1288
|
</ref>
|
1265
1289
|
</optional>
|
1290
|
+
<optional>
|
1291
|
+
<ref name="review-container">
|
1292
|
+
<a:documentation>Annotations to the document</a:documentation>
|
1293
|
+
</ref>
|
1294
|
+
</optional>
|
1266
1295
|
</element>
|
1267
1296
|
</define>
|
1268
1297
|
<define name="misccontainer">
|
@@ -1273,6 +1302,13 @@ numbers</a:documentation>
|
|
1273
1302
|
</oneOrMore>
|
1274
1303
|
</element>
|
1275
1304
|
</define>
|
1305
|
+
<define name="review-container">
|
1306
|
+
<element name="review-container">
|
1307
|
+
<oneOrMore>
|
1308
|
+
<ref name="review"/>
|
1309
|
+
</oneOrMore>
|
1310
|
+
</element>
|
1311
|
+
</define>
|
1276
1312
|
<define name="preface">
|
1277
1313
|
<element name="preface">
|
1278
1314
|
<oneOrMore>
|
@@ -147,6 +147,30 @@ module Metanorma
|
|
147
147
|
end
|
148
148
|
end
|
149
149
|
|
150
|
+
class TrStyleInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
151
|
+
use_dsl
|
152
|
+
named :"tr-style"
|
153
|
+
parse_content_as :text
|
154
|
+
using_format :short
|
155
|
+
|
156
|
+
def process(parent, _target, attrs)
|
157
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
158
|
+
%{<tr-style>#{out}</tr-style>}
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
class TdStyleInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
163
|
+
use_dsl
|
164
|
+
named :"td-style"
|
165
|
+
parse_content_as :text
|
166
|
+
using_format :short
|
167
|
+
|
168
|
+
def process(parent, _target, attrs)
|
169
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
170
|
+
%{<td-style>#{out}</td-style>}
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
150
174
|
class NumberInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
151
175
|
include ::Metanorma::Standoc::Utils
|
152
176
|
|
@@ -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!"
|
@@ -52,7 +52,7 @@ module Metanorma
|
|
52
52
|
|
53
53
|
PREFACE_CLAUSE_NAMES =
|
54
54
|
%w(abstract foreword introduction metanorma-extension termdocsource
|
55
|
-
misc-container acknowledgements).freeze
|
55
|
+
misc-container metanorma-extension acknowledgements).freeze
|
56
56
|
|
57
57
|
MAIN_CLAUSE_NAMES =
|
58
58
|
["normative references", "terms and definitions", "scope",
|
@@ -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
|
@@ -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,20 +32,18 @@ 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.1.
|
35
|
+
spec.add_dependency "isodoc", "~> 3.1.4"
|
36
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.3.0"
|
38
|
-
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.
|
38
|
+
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.2.3"
|
39
39
|
spec.add_dependency "metanorma-plugin-lutaml", "~> 0.7.0"
|
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,7 +51,8 @@ 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
|
54
|
+
spec.add_development_dependency "rubocop", "~> 1"
|
55
|
+
spec.add_development_dependency "rubocop-performance"
|
57
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"
|
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: 3.0.
|
4
|
+
version: 3.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-03-
|
11
|
+
date: 2025-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 3.1.
|
75
|
+
version: 3.1.4
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 3.1.
|
82
|
+
version: 3.1.4
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: metanorma
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.2.
|
117
|
+
version: 0.2.3
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.2.
|
124
|
+
version: 0.2.3
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: metanorma-plugin-lutaml
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,20 +164,6 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: asciimath2unitsml
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - "~>"
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: 0.4.0
|
174
|
-
type: :runtime
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - "~>"
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: 0.4.0
|
181
167
|
- !ruby/object:Gem::Dependency
|
182
168
|
name: concurrent-ruby
|
183
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -234,20 +220,6 @@ dependencies:
|
|
234
220
|
- - "~>"
|
235
221
|
- !ruby/object:Gem::Version
|
236
222
|
version: 1.2.0
|
237
|
-
- !ruby/object:Gem::Dependency
|
238
|
-
name: unicode2latex
|
239
|
-
requirement: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - "~>"
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: 0.0.1
|
244
|
-
type: :runtime
|
245
|
-
prerelease: false
|
246
|
-
version_requirements: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - "~>"
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: 0.0.1
|
251
223
|
- !ruby/object:Gem::Dependency
|
252
224
|
name: debug
|
253
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -338,14 +310,28 @@ dependencies:
|
|
338
310
|
requirements:
|
339
311
|
- - "~>"
|
340
312
|
- !ruby/object:Gem::Version
|
341
|
-
version: 1
|
313
|
+
version: '1'
|
342
314
|
type: :development
|
343
315
|
prerelease: false
|
344
316
|
version_requirements: !ruby/object:Gem::Requirement
|
345
317
|
requirements:
|
346
318
|
- - "~>"
|
347
319
|
- !ruby/object:Gem::Version
|
348
|
-
version: 1
|
320
|
+
version: '1'
|
321
|
+
- !ruby/object:Gem::Dependency
|
322
|
+
name: rubocop-performance
|
323
|
+
requirement: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - ">="
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '0'
|
328
|
+
type: :development
|
329
|
+
prerelease: false
|
330
|
+
version_requirements: !ruby/object:Gem::Requirement
|
331
|
+
requirements:
|
332
|
+
- - ">="
|
333
|
+
- !ruby/object:Gem::Version
|
334
|
+
version: '0'
|
349
335
|
- !ruby/object:Gem::Dependency
|
350
336
|
name: sassc-embedded
|
351
337
|
requirement: !ruby/object:Gem::Requirement
|