metanorma-standoc 3.0.3 → 3.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/isodoc/html/htmlstyle.css +7 -0
- data/lib/metanorma/standoc/base.rb +5 -7
- data/lib/metanorma/standoc/basicdoc.rng +48 -35
- data/lib/metanorma/standoc/biblio-standoc.rng +37 -7
- data/lib/metanorma/standoc/biblio.rng +30 -18
- data/lib/metanorma/standoc/blocks.rb +21 -1
- data/lib/metanorma/standoc/cleanup.rb +2 -0
- data/lib/metanorma/standoc/cleanup_bibdata.rb +17 -5
- data/lib/metanorma/standoc/cleanup_block.rb +1 -1
- data/lib/metanorma/standoc/cleanup_inline.rb +7 -6
- data/lib/metanorma/standoc/cleanup_maths.rb +2 -3
- data/lib/metanorma/standoc/cleanup_review.rb +60 -0
- data/lib/metanorma/standoc/cleanup_section.rb +3 -38
- data/lib/metanorma/standoc/cleanup_section_names.rb +25 -0
- data/lib/metanorma/standoc/cleanup_table.rb +22 -0
- data/lib/metanorma/standoc/cleanup_text.rb +11 -31
- data/lib/metanorma/standoc/cleanup_xref.rb +2 -37
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/front.rb +6 -3
- data/lib/metanorma/standoc/init.rb +1 -0
- data/lib/metanorma/standoc/inline.rb +0 -1
- data/lib/metanorma/standoc/isodoc.rng +126 -80
- data/lib/metanorma/standoc/macros_inline.rb +27 -1
- data/lib/metanorma/standoc/macros_note.rb +0 -1
- data/lib/metanorma/standoc/ref.rb +4 -26
- data/lib/metanorma/standoc/regex.rb +78 -0
- data/lib/metanorma/standoc/reqt.rng +7 -6
- data/lib/metanorma/standoc/section.rb +1 -1
- data/lib/metanorma/standoc/terms.rb +2 -9
- data/lib/metanorma/standoc/utils.rb +8 -0
- data/lib/metanorma/standoc/validate.rb +2 -46
- data/lib/metanorma/standoc/validate_schema.rb +104 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- metadata +9 -7
- data/Gemfile.devel +0 -1
@@ -16,16 +16,6 @@ module Metanorma
|
|
16
16
|
!path.intersection(ancestors).empty?
|
17
17
|
end
|
18
18
|
|
19
|
-
def linebreak_cleanup(xmldoc)
|
20
|
-
xmldoc.traverse do |x|
|
21
|
-
x.text? && x.text.include?("\n") or next
|
22
|
-
ancestor_include?(x, PRESERVE_LINEBREAK_ELEMENTS) and next
|
23
|
-
ancestor_include?(x, STRIP_LINEBREAK_ELEMENTS) or next
|
24
|
-
x.replace(Metanorma::Utils
|
25
|
-
.line_sanitise(x.text.lines.map(&:rstrip)).join)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
19
|
# process example/p, example/sourcecode, not example on its own:
|
30
20
|
# this is about stripping lines for blocks containing inline elems & text
|
31
21
|
def linebreak_cleanup(xmldoc)
|
@@ -57,11 +47,15 @@ module Metanorma
|
|
57
47
|
|
58
48
|
def gather_text_for_linebreak_cleanup(block)
|
59
49
|
x = block.xpath(".//text()").map do |e|
|
60
|
-
{ elem: e, text: e.text,
|
50
|
+
{ elem: e, text: e.text, stem: ancestor_include?(e, %w(stem)),
|
61
51
|
skip: ancestor_include?(e, PRESERVE_LINEBREAK_ELEMENTS) }
|
62
52
|
end
|
63
53
|
x.empty? and return x
|
64
54
|
x.each { |e| e[:skip] ||= !e[:text].include?("\n") }
|
55
|
+
x.each_with_index do |e, i|
|
56
|
+
# do not treat stem linebreaks as meaningful
|
57
|
+
e[:skip] ||= x[i + 1]&.dig(:stem)
|
58
|
+
end
|
65
59
|
x[-1][:last] = true
|
66
60
|
x
|
67
61
|
end
|
@@ -71,6 +65,9 @@ module Metanorma
|
|
71
65
|
if @smartquotes then smartquotes_cleanup1(xmldoc)
|
72
66
|
else dumbquote_cleanup(xmldoc)
|
73
67
|
end
|
68
|
+
xmldoc.xpath("//passthrough[@formats = 'straightquotes']").each do |x|
|
69
|
+
x.replace(x.children)
|
70
|
+
end
|
74
71
|
end
|
75
72
|
|
76
73
|
def smartquotes_cleanup1(xmldoc)
|
@@ -91,7 +88,7 @@ module Metanorma
|
|
91
88
|
# "abc<tag/>", def => "abc",<tag/> def
|
92
89
|
# TODO?
|
93
90
|
def uninterrupt_quotes_around_xml1(xmldoc)
|
94
|
-
|
91
|
+
xmldoc.xpath("//text()[preceding-sibling::*[1]]").each do |n|
|
95
92
|
uninterrupt_quotes_around_xml_skip(n) and next
|
96
93
|
uninterrupt_quotes_around_xml1(n.previous)
|
97
94
|
end
|
@@ -102,7 +99,7 @@ module Metanorma
|
|
102
99
|
identifier metanorma-extension).freeze
|
103
100
|
|
104
101
|
PRESERVE_LINEBREAK_ELEMENTS =
|
105
|
-
%w(pre sourcecode passthrough metanorma-extension).freeze
|
102
|
+
%w(pre sourcecode passthrough metanorma-extension stem).freeze
|
106
103
|
|
107
104
|
STRIP_LINEBREAK_ELEMENTS =
|
108
105
|
%w(title name variant-title figure example review admonition
|
@@ -157,29 +154,12 @@ module Metanorma
|
|
157
154
|
block?(x) and prev = ""
|
158
155
|
empty_tag_with_text_content?(x) and prev = "dummy"
|
159
156
|
x.text? or next
|
160
|
-
|
161
|
-
# ancestors = x.path.gsub(/\[\d+\]/, "").split(%r{/})[1..-2]
|
162
|
-
# ancestors.intersection(IGNORE_QUOTES_ELEMENTS).empty? or next
|
163
157
|
ancestor_include?(x, IGNORE_QUOTES_ELEMENTS) and next
|
164
158
|
dumb2smart_quotes1(x, prev)
|
165
159
|
prev = x.text
|
166
160
|
end
|
167
161
|
end
|
168
162
|
|
169
|
-
def dumb2smart_quotesx(xmldoc)
|
170
|
-
# TODO?>
|
171
|
-
prev = ""
|
172
|
-
xmldoc.xpath("//* | //text()").each do |x|
|
173
|
-
x.is_a?(Nokogiri::XML::Node) or next
|
174
|
-
block?(x) and prev = ""
|
175
|
-
empty_tag_with_text_content?(x) and prev = "dummy"
|
176
|
-
x.text? or next
|
177
|
-
ancestor_include?(x, IGNORE_QUOTES_ELEMENTS) and next
|
178
|
-
dumb2smart_quotes1(x, prev)
|
179
|
-
prev = x.text
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
163
|
def dumb2smart_quotes1(curr, prev)
|
184
164
|
/[-'"(<>]|\.\.|\dx/.match?(curr.text) or return
|
185
165
|
|
@@ -190,7 +170,7 @@ ancestor_include?(x, IGNORE_QUOTES_ELEMENTS) and next
|
|
190
170
|
|
191
171
|
def dumbquote_cleanup(xmldoc)
|
192
172
|
xmldoc.traverse do |n|
|
193
|
-
next unless n.text? &&
|
173
|
+
next unless n.text? && n.text.include?("\u2019")
|
194
174
|
|
195
175
|
n.replace(@c.encode(
|
196
176
|
@c.decode(n.text)
|
@@ -1,33 +1,6 @@
|
|
1
1
|
module Metanorma
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
|
-
# extending localities to cover ISO referencing
|
5
|
-
CONN_REGEX_STR = "(?<conn>and|or|from|to)!".freeze
|
6
|
-
|
7
|
-
LOCALITIES = "section|clause|part|paragraph|chapter|page|line|" \
|
8
|
-
"table|annex|figure|example|note|formula|list|time|anchor|" \
|
9
|
-
"locality:[^ \\t\\n\\r:,;=]+".freeze
|
10
|
-
|
11
|
-
LOCALITY_REGEX_STR = <<~REGEXP.freeze
|
12
|
-
^((#{CONN_REGEX_STR})?
|
13
|
-
(?<locality>#{LOCALITIES})(\\s+|=)
|
14
|
-
(?<ref>[^"][^ \\t\\n,:;-]*|"[^"]+")
|
15
|
-
(-(?<to>[^"][^ \\t\\n,:;-]*|"[^"]"))?|
|
16
|
-
(?<locality2>whole|title|locality:[^ \\t\\n\\r:,;=]+))(?<punct>[,:;]?)\\s*
|
17
|
-
(?<text>.*)$
|
18
|
-
REGEXP
|
19
|
-
|
20
|
-
def to_regex(str)
|
21
|
-
Regexp.new(str.gsub(/\s/, ""), Regexp::IGNORECASE | Regexp::MULTILINE)
|
22
|
-
end
|
23
|
-
|
24
|
-
LOCALITY_REGEX_VALUE_ONLY_STR = <<~REGEXP.freeze
|
25
|
-
^(?<conn0>(#{CONN_REGEX_STR}))
|
26
|
-
(?!whole|title|locality:)
|
27
|
-
(?<value>[^=,;:\\t\\n\\r]+)
|
28
|
-
(?<punct>[,;\\t\\n\\r]|$)
|
29
|
-
REGEXP
|
30
|
-
|
31
4
|
def tq(text)
|
32
5
|
text.sub(/^"/, "").sub(/"$/, "")
|
33
6
|
end
|
@@ -43,16 +16,6 @@ module Metanorma
|
|
43
16
|
d.children.empty? and d.remove
|
44
17
|
end
|
45
18
|
|
46
|
-
LOCALITY_REGEX_STR_TRIPLEDASH = <<~REGEXP.freeze
|
47
|
-
^(?<locality>(#{CONN_REGEX_STR})?
|
48
|
-
(#{LOCALITIES})(\\s+|=))
|
49
|
-
(?<ref>[^"][^ \\t\\n,:;-]*
|
50
|
-
-[^ \\t\\n,:;"-]+
|
51
|
-
-[^ \\t\\n,:;"]+)
|
52
|
-
(?<text>[,:;]?\\s*
|
53
|
-
.*)$
|
54
|
-
REGEXP
|
55
|
-
|
56
19
|
# treat n-n-n locality as "n-n-n", do not parse as a range
|
57
20
|
def locality_normalise(text)
|
58
21
|
re = to_regex(LOCALITY_REGEX_STR_TRIPLEDASH)
|
@@ -261,6 +224,8 @@ module Metanorma
|
|
261
224
|
extract_localities(x)
|
262
225
|
end
|
263
226
|
end
|
227
|
+
|
228
|
+
include ::Metanorma::Standoc::Regex
|
264
229
|
end
|
265
230
|
end
|
266
231
|
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,5 +1,4 @@
|
|
1
1
|
require "date"
|
2
|
-
require "htmlentities"
|
3
2
|
require "pathname"
|
4
3
|
require_relative "./front_contributor"
|
5
4
|
require "isoics"
|
@@ -13,7 +12,7 @@ module Metanorma
|
|
13
12
|
end
|
14
13
|
|
15
14
|
def metadata_id_build(node)
|
16
|
-
part, subpart = node&.attr("partnumber")&.split(
|
15
|
+
part, subpart = node&.attr("partnumber")&.split("-")
|
17
16
|
id = node.attr("docnumber") || ""
|
18
17
|
id += "-#{part}" if part
|
19
18
|
id += "-#{subpart}" if subpart
|
@@ -189,9 +188,12 @@ module Metanorma
|
|
189
188
|
metadata_flavor(node, ext)
|
190
189
|
metadata_committee(node, ext)
|
191
190
|
metadata_ics(node, ext)
|
191
|
+
structured_id(node, ext)
|
192
192
|
metadata_coverpage_images(node, ext)
|
193
193
|
end
|
194
194
|
|
195
|
+
def structured_id(node, xml); end
|
196
|
+
|
195
197
|
def metadata_doctype(node, xml)
|
196
198
|
xml.doctype doctype(node)
|
197
199
|
end
|
@@ -218,7 +220,8 @@ module Metanorma
|
|
218
220
|
at = { language: lang, format: "text/plain" }
|
219
221
|
xml.title **attr_code(at) do |t|
|
220
222
|
title = Metanorma::Utils::asciidoc_sub(
|
221
|
-
node.attr("title") || node.attr("title-en") || node.attr("doctitle")
|
223
|
+
node.attr("title") || node.attr("title-en") || node.attr("doctitle"),
|
224
|
+
)
|
222
225
|
t << title
|
223
226
|
end
|
224
227
|
end
|
@@ -1,24 +1,27 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!--
|
3
|
-
instantiations of this grammar may replace leaf strings
|
4
|
-
with more elaborated types; e.g. title (text) replaced with
|
5
|
-
title-main, title-intro, title-part; type replaced with
|
6
|
-
enum.
|
7
|
-
|
8
|
-
some renaming at leaf nodes is permissible
|
9
|
-
|
10
|
-
obligations can change both from optional to mandatory,
|
11
|
-
and from mandatory to optional; optional elements may
|
12
|
-
be omitted; freely positioned alternatives may be replaced
|
13
|
-
with strict ordering
|
14
|
-
|
15
|
-
DO NOT introduce a namespace here. We do not want a distinct namespace
|
16
|
-
for these elements, and a distinct namespace for any grammar inheriting
|
17
|
-
these elements; we just want one namespace for any child grammars
|
18
|
-
of this.
|
19
|
-
-->
|
20
|
-
<!-- VERSION v2.0.0 -->
|
21
2
|
<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">
|
3
|
+
<!-- VERSION v2.0.3 -->
|
4
|
+
|
5
|
+
<!--
|
6
|
+
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
7
|
+
|
8
|
+
instantiations of this grammar may replace leaf strings
|
9
|
+
with more elaborated types; e.g. title (text) replaced with
|
10
|
+
title-main, title-intro, title-part; type replaced with
|
11
|
+
enum.
|
12
|
+
|
13
|
+
some renaming at leaf nodes is permissible
|
14
|
+
|
15
|
+
obligations can change both from optional to mandatory,
|
16
|
+
and from mandatory to optional; optional elements may
|
17
|
+
be omitted; freely positioned alternatives may be replaced
|
18
|
+
with strict ordering
|
19
|
+
|
20
|
+
DO NOT introduce a namespace here. We do not want a distinct namespace
|
21
|
+
for these elements, and a distinct namespace for any grammar inheriting
|
22
|
+
these elements; we just want one namespace for any child grammars
|
23
|
+
of this.
|
24
|
+
-->
|
22
25
|
<include href="reqt.rng"/>
|
23
26
|
<include href="basicdoc.rng">
|
24
27
|
<define name="amend">
|
@@ -33,15 +36,6 @@
|
|
33
36
|
</zeroOrMore>
|
34
37
|
</element>
|
35
38
|
</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>
|
45
39
|
<define name="index-primary">
|
46
40
|
<element name="primary">
|
47
41
|
<oneOrMore>
|
@@ -423,6 +417,13 @@ normative or informative references, some split references into sections organiz
|
|
423
417
|
</oneOrMore>
|
424
418
|
</choice>
|
425
419
|
</define>
|
420
|
+
<define name="TrAttributes">
|
421
|
+
<optional>
|
422
|
+
<attribute name="style">
|
423
|
+
<a:documentation>CSS style: only background-color supported</a:documentation>
|
424
|
+
</attribute>
|
425
|
+
</optional>
|
426
|
+
</define>
|
426
427
|
<define name="table-note">
|
427
428
|
<element name="note">
|
428
429
|
<ref name="OptionalId"/>
|
@@ -485,6 +486,22 @@ gives an explicit page orientation</a:documentation>
|
|
485
486
|
</define>
|
486
487
|
</include>
|
487
488
|
<!-- end overrides -->
|
489
|
+
<define name="FnAttributes" combine="interleave">
|
490
|
+
<optional>
|
491
|
+
<attribute name="hiddenref">
|
492
|
+
<a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
|
493
|
+
This is done if the footnote reference is already presented in some other form, e.g. within a figure image.</a:documentation>
|
494
|
+
<data type="boolean"/>
|
495
|
+
</attribute>
|
496
|
+
</optional>
|
497
|
+
</define>
|
498
|
+
<define name="TdAttributes" combine="interleave">
|
499
|
+
<optional>
|
500
|
+
<attribute name="style">
|
501
|
+
<a:documentation>CSS style: only background-color supported</a:documentation>
|
502
|
+
</attribute>
|
503
|
+
</optional>
|
504
|
+
</define>
|
488
505
|
<define name="NumberingAttributes" combine="interleave">
|
489
506
|
<optional>
|
490
507
|
<attribute name="number">
|
@@ -663,6 +680,13 @@ titlecase, or lowercase</a:documentation>
|
|
663
680
|
</attribute>
|
664
681
|
</optional>
|
665
682
|
</define>
|
683
|
+
<define name="Basic-Section-Attributes" combine="interleave">
|
684
|
+
<optional>
|
685
|
+
<attribute name="obligation">
|
686
|
+
<ref name="ObligationType"/>
|
687
|
+
</attribute>
|
688
|
+
</optional>
|
689
|
+
</define>
|
666
690
|
<define name="ObligationType">
|
667
691
|
<a:documentation>The force of a clause in a standard document: whether it has normative or informative effect</a:documentation>
|
668
692
|
<choice>
|
@@ -1177,13 +1201,6 @@ numbers</a:documentation>
|
|
1177
1201
|
</attribute>
|
1178
1202
|
</optional>
|
1179
1203
|
</define>
|
1180
|
-
<define name="Basic-Section-Attributes" combine="interleave">
|
1181
|
-
<optional>
|
1182
|
-
<attribute name="obligation">
|
1183
|
-
<ref name="ObligationType"/>
|
1184
|
-
</attribute>
|
1185
|
-
</optional>
|
1186
|
-
</define>
|
1187
1204
|
<define name="reference-clause">
|
1188
1205
|
<a:documentation>References clause with recursive nesting</a:documentation>
|
1189
1206
|
<element name="clause">
|
@@ -1224,7 +1241,7 @@ numbers</a:documentation>
|
|
1224
1241
|
</choice>
|
1225
1242
|
</attribute>
|
1226
1243
|
<attribute name="flavor">
|
1227
|
-
<a:documentation>Metanorma flavor, indicating SDO whose
|
1244
|
+
<a:documentation>Metanorma flavor, indicating SDO whose requirements the realisation aligns to</a:documentation>
|
1228
1245
|
</attribute>
|
1229
1246
|
</define>
|
1230
1247
|
<define name="standard-document">
|
@@ -1234,6 +1251,11 @@ numbers</a:documentation>
|
|
1234
1251
|
<ref name="bibdata">
|
1235
1252
|
<a:documentation>Bibliographic description of the document itself, expressed in the Relaton model</a:documentation>
|
1236
1253
|
</ref>
|
1254
|
+
<zeroOrMore>
|
1255
|
+
<ref name="termdocsource">
|
1256
|
+
<a:documentation>Source for term definitions in the document</a:documentation>
|
1257
|
+
</ref>
|
1258
|
+
</zeroOrMore>
|
1237
1259
|
<optional>
|
1238
1260
|
<ref name="misccontainer">
|
1239
1261
|
<a:documentation>Extension point for extraneous elements that need to be added to standards document as data</a:documentation>
|
@@ -1244,36 +1266,44 @@ numbers</a:documentation>
|
|
1244
1266
|
<a:documentation>Front matter that is repeated at the start of documents issued from an SDO, with content not specific to the document</a:documentation>
|
1245
1267
|
</ref>
|
1246
1268
|
</optional>
|
1269
|
+
<ref name="DocumentBody"/>
|
1247
1270
|
<optional>
|
1248
|
-
<ref name="
|
1249
|
-
<a:documentation>
|
1250
|
-
</ref>
|
1251
|
-
</optional>
|
1252
|
-
<ref name="sections">
|
1253
|
-
<a:documentation>Main body of document</a:documentation>
|
1254
|
-
</ref>
|
1255
|
-
<zeroOrMore>
|
1256
|
-
<ref name="annex">
|
1257
|
-
<a:documentation>Annex sections</a:documentation>
|
1258
|
-
</ref>
|
1259
|
-
</zeroOrMore>
|
1260
|
-
<optional>
|
1261
|
-
<ref name="bibliography">
|
1262
|
-
<a:documentation>Bibliographic sections</a:documentation>
|
1263
|
-
</ref>
|
1264
|
-
</optional>
|
1265
|
-
<zeroOrMore>
|
1266
|
-
<ref name="indexsect">
|
1267
|
-
<a:documentation>Index of the document</a:documentation>
|
1268
|
-
</ref>
|
1269
|
-
</zeroOrMore>
|
1270
|
-
<optional>
|
1271
|
-
<ref name="colophon">
|
1272
|
-
<a:documentation>Colophon or postface material</a:documentation>
|
1271
|
+
<ref name="review-container">
|
1272
|
+
<a:documentation>Annotations to the document</a:documentation>
|
1273
1273
|
</ref>
|
1274
1274
|
</optional>
|
1275
1275
|
</element>
|
1276
1276
|
</define>
|
1277
|
+
<define name="DocumentBody">
|
1278
|
+
<optional>
|
1279
|
+
<ref name="preface">
|
1280
|
+
<a:documentation>Prefatory sections</a:documentation>
|
1281
|
+
</ref>
|
1282
|
+
</optional>
|
1283
|
+
<ref name="sections">
|
1284
|
+
<a:documentation>Main body of document</a:documentation>
|
1285
|
+
</ref>
|
1286
|
+
<zeroOrMore>
|
1287
|
+
<ref name="annex">
|
1288
|
+
<a:documentation>Annex sections</a:documentation>
|
1289
|
+
</ref>
|
1290
|
+
</zeroOrMore>
|
1291
|
+
<optional>
|
1292
|
+
<ref name="bibliography">
|
1293
|
+
<a:documentation>Bibliographic sections</a:documentation>
|
1294
|
+
</ref>
|
1295
|
+
</optional>
|
1296
|
+
<zeroOrMore>
|
1297
|
+
<ref name="indexsect">
|
1298
|
+
<a:documentation>Index of the document</a:documentation>
|
1299
|
+
</ref>
|
1300
|
+
</zeroOrMore>
|
1301
|
+
<optional>
|
1302
|
+
<ref name="colophon">
|
1303
|
+
<a:documentation>Colophon or postface material</a:documentation>
|
1304
|
+
</ref>
|
1305
|
+
</optional>
|
1306
|
+
</define>
|
1277
1307
|
<define name="misccontainer">
|
1278
1308
|
<a:documentation>Elements added to metanorma-extension are open-ended, and constitute source data</a:documentation>
|
1279
1309
|
<element name="metanorma-extension">
|
@@ -1282,6 +1312,13 @@ numbers</a:documentation>
|
|
1282
1312
|
</oneOrMore>
|
1283
1313
|
</element>
|
1284
1314
|
</define>
|
1315
|
+
<define name="review-container">
|
1316
|
+
<element name="review-container">
|
1317
|
+
<oneOrMore>
|
1318
|
+
<ref name="review"/>
|
1319
|
+
</oneOrMore>
|
1320
|
+
</element>
|
1321
|
+
</define>
|
1285
1322
|
<define name="preface">
|
1286
1323
|
<element name="preface">
|
1287
1324
|
<oneOrMore>
|
@@ -1581,9 +1618,7 @@ used in document amendments</a:documentation>
|
|
1581
1618
|
<define name="term">
|
1582
1619
|
<a:documentation>Terminology entry with its definition</a:documentation>
|
1583
1620
|
<element name="term">
|
1584
|
-
<ref name="
|
1585
|
-
<ref name="LocalizedStringAttributes"/>
|
1586
|
-
<ref name="BlockAttributes"/>
|
1621
|
+
<ref name="TermAttributes"/>
|
1587
1622
|
<oneOrMore>
|
1588
1623
|
<ref name="preferred">
|
1589
1624
|
<a:documentation>One or more names under which the term being defined is canonically known</a:documentation>
|
@@ -1635,6 +1670,11 @@ used in document amendments</a:documentation>
|
|
1635
1670
|
</ref>
|
1636
1671
|
</element>
|
1637
1672
|
</define>
|
1673
|
+
<define name="TermAttributes">
|
1674
|
+
<ref name="OptionalId"/>
|
1675
|
+
<ref name="LocalizedStringAttributes"/>
|
1676
|
+
<ref name="BlockAttributes"/>
|
1677
|
+
</define>
|
1638
1678
|
<define name="preferred">
|
1639
1679
|
<element name="preferred">
|
1640
1680
|
<ref name="Designation"/>
|
@@ -2296,26 +2336,32 @@ links within an SVG file, so that the SVG file can hyperlink to anchors within t
|
|
2296
2336
|
</element>
|
2297
2337
|
</define>
|
2298
2338
|
<define name="ul_li">
|
2299
|
-
<a:documentation>
|
2339
|
+
<a:documentation>Unordered list item for standards documents</a:documentation>
|
2300
2340
|
<element name="li">
|
2301
2341
|
<ref name="OptionalId"/>
|
2302
|
-
<
|
2303
|
-
|
2304
|
-
<a:documentation>Include a checkbox for the list item</a:documentation>
|
2305
|
-
<data type="boolean"/>
|
2306
|
-
</attribute>
|
2307
|
-
</optional>
|
2308
|
-
<optional>
|
2309
|
-
<attribute name="checkedcheckbox">
|
2310
|
-
<a:documentation>Check the checkbox for the list item</a:documentation>
|
2311
|
-
<data type="boolean"/>
|
2312
|
-
</attribute>
|
2313
|
-
</optional>
|
2314
|
-
<oneOrMore>
|
2315
|
-
<ref name="BasicBlock"/>
|
2316
|
-
</oneOrMore>
|
2342
|
+
<ref name="UlLiAttributes"/>
|
2343
|
+
<ref name="UlLiBody"/>
|
2317
2344
|
</element>
|
2318
2345
|
</define>
|
2346
|
+
<define name="UlLiBody">
|
2347
|
+
<oneOrMore>
|
2348
|
+
<ref name="BasicBlock"/>
|
2349
|
+
</oneOrMore>
|
2350
|
+
</define>
|
2351
|
+
<define name="UlLiAttributes">
|
2352
|
+
<optional>
|
2353
|
+
<attribute name="uncheckedcheckbox">
|
2354
|
+
<a:documentation>Include a checkbox for the list item</a:documentation>
|
2355
|
+
<data type="boolean"/>
|
2356
|
+
</attribute>
|
2357
|
+
</optional>
|
2358
|
+
<optional>
|
2359
|
+
<attribute name="checkedcheckbox">
|
2360
|
+
<a:documentation>Check the checkbox for the list item</a:documentation>
|
2361
|
+
<data type="boolean"/>
|
2362
|
+
</attribute>
|
2363
|
+
</optional>
|
2364
|
+
</define>
|
2319
2365
|
<define name="floating-title">
|
2320
2366
|
<a:documentation>A floating title, outside of the clause hierarchy of the document</a:documentation>
|
2321
2367
|
<element name="floating-title">
|
@@ -114,10 +114,12 @@ module Metanorma
|
|
114
114
|
class PassInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
115
115
|
use_dsl
|
116
116
|
named :"pass-format"
|
117
|
+
parse_content_as :text
|
117
118
|
|
118
119
|
def process(parent, target, attrs)
|
120
|
+
#require "debug"; binding.b
|
119
121
|
format = target || "metanorma"
|
120
|
-
out = Asciidoctor::Inline.new(parent, :quoted, attrs[
|
122
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
121
123
|
.gsub(/((?![<>&])[[:punct:]])/, "\\1‌")
|
122
124
|
%{<passthrough-inline formats="#{format}">#{out}</passthrough-inline>}
|
123
125
|
end
|
@@ -147,6 +149,30 @@ module Metanorma
|
|
147
149
|
end
|
148
150
|
end
|
149
151
|
|
152
|
+
class TrStyleInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
153
|
+
use_dsl
|
154
|
+
named :"tr-style"
|
155
|
+
parse_content_as :text
|
156
|
+
using_format :short
|
157
|
+
|
158
|
+
def process(parent, _target, attrs)
|
159
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
160
|
+
%{<tr-style>#{out}</tr-style>}
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
class TdStyleInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
165
|
+
use_dsl
|
166
|
+
named :"td-style"
|
167
|
+
parse_content_as :text
|
168
|
+
using_format :short
|
169
|
+
|
170
|
+
def process(parent, _target, attrs)
|
171
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
172
|
+
%{<td-style>#{out}</td-style>}
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
150
176
|
class NumberInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
151
177
|
include ::Metanorma::Standoc::Utils
|
152
178
|
|
@@ -67,7 +67,7 @@ module Metanorma
|
|
67
67
|
iso_publisher(t, match[:code])
|
68
68
|
unless match[:fn].nil?
|
69
69
|
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
70
|
-
p <<
|
70
|
+
p << match[:fn].to_s
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -99,7 +99,7 @@ module Metanorma
|
|
99
99
|
iso_publisher(t, match[:code])
|
100
100
|
if match.names.include?("fn") && match[:fn]
|
101
101
|
t.note(**plaintxt.merge(type: "Unpublished-Status")) do |p|
|
102
|
-
p <<
|
102
|
+
p << match[:fn].to_s
|
103
103
|
end
|
104
104
|
end
|
105
105
|
t.extent type: "part" do |e|
|
@@ -184,30 +184,6 @@ module Metanorma
|
|
184
184
|
use_retrieved_relaton(item, xml)
|
185
185
|
end
|
186
186
|
|
187
|
-
ISO_REF =
|
188
|
-
%r{^<ref\sid="(?<anchor>[^"]+)">
|
189
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9-]+|IEV)
|
190
|
-
(?::(?<year>[0-9][0-9-]+))?\]</ref>,?\s*(?<text>.*)$}xm
|
191
|
-
|
192
|
-
ISO_REF_NO_YEAR =
|
193
|
-
%r{^<ref\sid="(?<anchor>[^"]+)">
|
194
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9-]+):
|
195
|
-
(?:--|–|—|&\#821[12];)\]</ref>,?\s*
|
196
|
-
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>)?,?\s?(?<text>.*)$}xm
|
197
|
-
|
198
|
-
ISO_REF_ALL_PARTS =
|
199
|
-
%r{^<ref\sid="(?<anchor>[^"]+)">
|
200
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>(?:ISO|IEC)[^0-9]*\s[0-9]+)
|
201
|
-
(?::(?<year>--|–|—|&\#821[12];|[0-9][0-9-]+))?\s
|
202
|
-
\(all\sparts\)\]</ref>,?\s*
|
203
|
-
(?:<fn[^>]*>\s*<p>(?<fn>[^\]]+)</p>\s*</fn>,?\s?)?(?<text>.*)$}xm
|
204
|
-
|
205
|
-
NON_ISO_REF = %r{^<ref\sid="(?<anchor>[^"]+)">
|
206
|
-
\[(?<usrlbl>\([^)]+\))?(?<code>.+?)\]</ref>,?\s*(?<text>.*)$}xm
|
207
|
-
|
208
|
-
NON_ISO_REF1 = %r{^<ref\sid="(?<anchor>[^"]+)">
|
209
|
-
(?<usrlbl>\([^)]+\))?(?<code>.+?)</ref>,?\s*(?<text>.*)$}xm
|
210
|
-
|
211
187
|
def reference1_matches(item)
|
212
188
|
matched = ISO_REF.match item
|
213
189
|
matched2 = ISO_REF_NO_YEAR.match item
|
@@ -233,6 +209,8 @@ module Metanorma
|
|
233
209
|
when 3 then isorefmatches3out(item, xml)
|
234
210
|
end
|
235
211
|
end
|
212
|
+
|
213
|
+
include ::Metanorma::Standoc::Regex
|
236
214
|
end
|
237
215
|
end
|
238
216
|
end
|