metanorma-standoc 3.0.9 → 3.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/anchor.rb +1 -1
- data/lib/metanorma/standoc/blocks.rb +11 -4
- data/lib/metanorma/standoc/blocks_image.rb +3 -8
- data/lib/metanorma/standoc/blocks_notes.rb +1 -1
- data/lib/metanorma/standoc/cleanup_bibdata.rb +1 -1
- data/lib/metanorma/standoc/cleanup_bibitem.rb +3 -2
- data/lib/metanorma/standoc/cleanup_footnotes.rb +1 -0
- data/lib/metanorma/standoc/cleanup_section.rb +1 -1
- data/lib/metanorma/standoc/cleanup_section_names.rb +3 -2
- data/lib/metanorma/standoc/cleanup_terms.rb +14 -3
- data/lib/metanorma/standoc/converter.rb +2 -1
- data/lib/metanorma/standoc/init.rb +9 -3
- data/lib/metanorma/standoc/isodoc.rng +19 -2
- data/lib/metanorma/standoc/lists.rb +2 -2
- data/lib/metanorma/standoc/macros.rb +46 -1
- data/lib/metanorma/standoc/macros_inline.rb +20 -3
- data/lib/metanorma/standoc/ref_sect.rb +2 -2
- data/lib/metanorma/standoc/render.rb +22 -13
- data/lib/metanorma/standoc/section.rb +16 -11
- data/lib/metanorma/standoc/table.rb +2 -6
- data/lib/metanorma/standoc/terms.rb +4 -3
- data/lib/metanorma/standoc/utils.rb +4 -0
- data/lib/metanorma/standoc/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db6d5e84280a719a76127b82021c52b54a140d3238f49ee7a5ac7c972d142e37
|
4
|
+
data.tar.gz: a0b7796f74365c18f35d05b27bffc7fbb369def03e1d29753ddeb7adbc9bef86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6991e701daa845955fc12f72f602eab1947ff397ecad2e8514e3ec9a9b04fdfa68fa0e6d946b3a8d53ae6d1feb8fcb78ff81f5d71e17ffa580157cda891ccde
|
7
|
+
data.tar.gz: d9025688e127d12e7103537af3d8d6f50b8d1c6a67eff352a365a0ebcb67acb7d976bbfb391dd30980df56b193bf3a56c99d98db6f326e4ede057cc29b3bf935
|
@@ -47,6 +47,13 @@ module Metanorma
|
|
47
47
|
result
|
48
48
|
end
|
49
49
|
|
50
|
+
def block_title(node, out)
|
51
|
+
node.title.nil? and return
|
52
|
+
out.name **attr_code(id_attr(nil)) do |name|
|
53
|
+
name << node.title
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
50
57
|
def form_attrs(node)
|
51
58
|
attr_code(id_attr(node)
|
52
59
|
.merge(class: node.attr("class"),
|
@@ -68,7 +75,7 @@ module Metanorma
|
|
68
75
|
def literal(node)
|
69
76
|
noko do |xml|
|
70
77
|
xml.figure **literal_attrs(node) do |f|
|
71
|
-
|
78
|
+
block_title(node, f)
|
72
79
|
pre_attrs = id_attr(node).tap { |h| h.delete(:anchor) }
|
73
80
|
.merge(alt: node.attr("alt"))
|
74
81
|
f.pre node.lines.join("\n"), **attr_code(pre_attrs)
|
@@ -128,7 +135,7 @@ module Metanorma
|
|
128
135
|
node.blocks.each { |b| b.remove_sub(:replacements) }
|
129
136
|
noko do |xml|
|
130
137
|
xml.figure **example_attrs(node).merge(class: "pseudocode") do |ex|
|
131
|
-
|
138
|
+
block_title(node, ex)
|
132
139
|
wrap_in_para(node, ex)
|
133
140
|
end
|
134
141
|
end
|
@@ -141,7 +148,7 @@ module Metanorma
|
|
141
148
|
def example_proper(node)
|
142
149
|
noko do |xml|
|
143
150
|
xml.example **example_attrs(node) do |ex|
|
144
|
-
node
|
151
|
+
block_title(node, xml)
|
145
152
|
wrap_in_para(node, ex)
|
146
153
|
end
|
147
154
|
end
|
@@ -203,7 +210,7 @@ module Metanorma
|
|
203
210
|
def listing(node)
|
204
211
|
fragment = ::Nokogiri::XML::Builder.new do |xml|
|
205
212
|
xml.sourcecode **listing_attrs(node) do |s|
|
206
|
-
|
213
|
+
block_title(node, s)
|
207
214
|
s.body do |b|
|
208
215
|
b << node.content
|
209
216
|
end
|
@@ -10,7 +10,7 @@ module Metanorma
|
|
10
10
|
xml.svgmap **attr_code(svgmap_attrs(node).merge(
|
11
11
|
src: node.attr("src"), alt: node.attr("alt"),
|
12
12
|
)) do |ex|
|
13
|
-
|
13
|
+
block_title(node, ex)
|
14
14
|
ex << node.content
|
15
15
|
end
|
16
16
|
end
|
@@ -19,17 +19,12 @@ module Metanorma
|
|
19
19
|
def figure_example(node)
|
20
20
|
noko do |xml|
|
21
21
|
xml.figure **figure_attrs(node) do |ex|
|
22
|
-
node
|
22
|
+
block_title(node, ex)
|
23
23
|
wrap_in_para(node, ex)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def figure_title(node, out)
|
29
|
-
node.title.nil? and return
|
30
|
-
out.name { |name| name << node.title }
|
31
|
-
end
|
32
|
-
|
33
28
|
def figure_attrs(node)
|
34
29
|
attr_code(id_unnum_attrs(node).merge(keep_attrs(node))
|
35
30
|
.merge(class: node.attr("class"),
|
@@ -39,7 +34,7 @@ module Metanorma
|
|
39
34
|
def image(node)
|
40
35
|
noko do |xml|
|
41
36
|
xml.figure **figure_attrs(node) do |f|
|
42
|
-
|
37
|
+
block_title(node, f)
|
43
38
|
f.image **(image_attributes(node).tap { |h| h.delete(:anchor) })
|
44
39
|
end
|
45
40
|
end
|
@@ -96,7 +96,7 @@ module Metanorma
|
|
96
96
|
ret = admonition_alternatives(node) and return ret
|
97
97
|
noko do |xml|
|
98
98
|
xml.admonition **admonition_attrs(node) do |a|
|
99
|
-
node
|
99
|
+
block_title(node, a)
|
100
100
|
wrap_in_para(node, a)
|
101
101
|
end
|
102
102
|
end
|
@@ -52,7 +52,7 @@ module Metanorma
|
|
52
52
|
i = i.add_child("<references hidden='true' normative='false'/>").first
|
53
53
|
refs.each do |x|
|
54
54
|
i << <<~BIB
|
55
|
-
<bibitem anchor="#{x}"
|
55
|
+
<bibitem anchor="#{x}" #{add_id_text} type="internal">
|
56
56
|
<docidentifier type="repository">#{x.sub(/^#{prefix}_/, "#{prefix}/")}</docidentifier>
|
57
57
|
</bibitem>
|
58
58
|
BIB
|
@@ -174,7 +174,7 @@ module Metanorma
|
|
174
174
|
@datauriattachment and
|
175
175
|
f = File.join(@attachmentsdir, File.basename(path))
|
176
176
|
Pathname.new(File.expand_path(f))
|
177
|
-
.relative_path_from(Pathname.new(File.expand_path(@
|
177
|
+
.relative_path_from(Pathname.new(File.expand_path(@output_dir))).to_s
|
178
178
|
end
|
179
179
|
|
180
180
|
def datauri_attachment(path, doc)
|
@@ -182,7 +182,7 @@ module Metanorma
|
|
182
182
|
m = add_misc_container(doc)
|
183
183
|
f = attachment_location(path)
|
184
184
|
e = (m << "<attachment name='#{f}'/>").last_element_child
|
185
|
-
Vectory::Utils::datauri(path, @
|
185
|
+
Vectory::Utils::datauri(path, @output_dir).scan(/.{1,60}/)
|
186
186
|
.each { |dd| e << "#{dd}\n" }
|
187
187
|
f
|
188
188
|
end
|
@@ -196,6 +196,7 @@ module Metanorma
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def init_attachments
|
199
|
+
@datauriattachment or return
|
199
200
|
@attachmentsdir and return
|
200
201
|
@attachmentsfld = "_#{@filename}_attachments"
|
201
202
|
@attachmentsdir = File.join(@output_dir, @attachmentsfld)
|
@@ -9,7 +9,9 @@ module Metanorma
|
|
9
9
|
node.children.first.previous = "<title/>"
|
10
10
|
end
|
11
11
|
end
|
12
|
-
node.at("./title")
|
12
|
+
ret = node.at("./title")
|
13
|
+
add_id(ret)
|
14
|
+
ret
|
13
15
|
end
|
14
16
|
|
15
17
|
def replace_title(doc, xpath, text, first = false)
|
@@ -149,7 +151,6 @@ module Metanorma
|
|
149
151
|
path = section_containers.map { |x| "./ancestor::#{x}" }.join(" | ")
|
150
152
|
xml.xpath("//p[@variant_title]").each do |p|
|
151
153
|
p.name = "variant-title"
|
152
|
-
p.delete("id")
|
153
154
|
p.delete("variant_title")
|
154
155
|
p.xpath("(#{path})[last()]").each do |sect|
|
155
156
|
(ins = sect.at("./title") and ins.next = p) or
|
@@ -34,6 +34,7 @@ module Metanorma
|
|
34
34
|
xmldoc.xpath("//term[not(definition)]").each do |d|
|
35
35
|
first_child = d.at(TERMDEF_BLOCKS) || next
|
36
36
|
t = Nokogiri::XML::Element.new("definition", xmldoc)
|
37
|
+
add_id(t)
|
37
38
|
first_child.replace(t)
|
38
39
|
t << first_child.remove
|
39
40
|
d.xpath(TERMDEF_BLOCKS).each do |n|
|
@@ -45,10 +46,13 @@ module Metanorma
|
|
45
46
|
def split_termdefinitions(xmldoc)
|
46
47
|
xmldoc.xpath("//definition").each do |d|
|
47
48
|
if d.at("./p | ./ol | ./dl | ./ul")
|
48
|
-
d.children =
|
49
|
+
d.children = <<~XML.strip
|
50
|
+
<verbal-definition #{add_id_text}>#{d.children}</verbal-definition>
|
51
|
+
XML
|
49
52
|
else
|
50
|
-
d.children =
|
51
|
-
|
53
|
+
d.children = <<~XML.strip
|
54
|
+
<non-verbal-representation #{add_id_text}>#{d.children}</non-verbal-representation>
|
55
|
+
XML
|
52
56
|
end
|
53
57
|
end
|
54
58
|
end
|
@@ -124,9 +128,16 @@ module Metanorma
|
|
124
128
|
termdefinition_cleanup(xmldoc)
|
125
129
|
termdomain1_cleanup(xmldoc)
|
126
130
|
termnote_example_cleanup(xmldoc)
|
131
|
+
term_id_attr_cleanup(xmldoc)
|
127
132
|
term_children_cleanup(xmldoc)
|
128
133
|
end
|
129
134
|
|
135
|
+
def term_id_attr_cleanup(xmldoc)
|
136
|
+
xmldoc.xpath("//usage-info[@id]").each do |u|
|
137
|
+
u.delete("id")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
130
141
|
def term_index_cleanup(xmldoc)
|
131
142
|
@index_terms or return
|
132
143
|
xmldoc.xpath("//preferred").each do |p|
|
@@ -35,6 +35,7 @@ module Metanorma
|
|
35
35
|
block_macro Metanorma::Plugin::Lutaml::LutamlKlassTableBlockMacro
|
36
36
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
37
37
|
preprocessor Metanorma::Standoc::LinkProtectPreprocessor
|
38
|
+
preprocessor Metanorma::Standoc::PassProtectPreprocessor
|
38
39
|
preprocessor Metanorma::Standoc::Datamodel::AttributesTablePreprocessor
|
39
40
|
preprocessor Metanorma::Standoc::Datamodel::DiagramPreprocessor
|
40
41
|
preprocessor Metanorma::Plugin::Lutaml::Json2TextPreprocessor
|
@@ -69,7 +70,7 @@ module Metanorma
|
|
69
70
|
inline_macro Metanorma::Standoc::FormSelectMacro
|
70
71
|
inline_macro Metanorma::Standoc::FormOptionMacro
|
71
72
|
inline_macro Metanorma::Standoc::ToCInlineMacro
|
72
|
-
inline_macro Metanorma::Standoc::
|
73
|
+
inline_macro Metanorma::Standoc::PassFormatInlineMacro
|
73
74
|
inline_macro Metanorma::Standoc::StdLinkInlineMacro
|
74
75
|
inline_macro Metanorma::Standoc::NumberInlineMacro
|
75
76
|
inline_macro Metanorma::Standoc::TrStyleInlineMacro
|
@@ -105,14 +105,20 @@ module Metanorma
|
|
105
105
|
@output_dir = outputdir node
|
106
106
|
end
|
107
107
|
|
108
|
+
def i18nyaml_path(node)
|
109
|
+
if i18nyaml = node.attr("i18nyaml")
|
110
|
+
(Pathname.new i18nyaml).absolute? or
|
111
|
+
i18nyaml = File.join(@localdir, i18nyaml)
|
112
|
+
end
|
113
|
+
i18nyaml
|
114
|
+
end
|
115
|
+
|
108
116
|
def init_i18n(node)
|
109
117
|
@lang = node.attr("language") || "en"
|
110
118
|
@script = node.attr("script") ||
|
111
119
|
Metanorma::Utils.default_script(node.attr("language"))
|
112
120
|
@locale = node.attr("locale")
|
113
|
-
|
114
|
-
i18nyaml &&= File.join(@localdir, i18nyaml)
|
115
|
-
@isodoc = isodoc(@lang, @script, @locale, i18nyaml)
|
121
|
+
@isodoc = isodoc(@lang, @script, @locale, i18nyaml_path(node))
|
116
122
|
@i18n = @isodoc.i18n
|
117
123
|
end
|
118
124
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
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
|
+
<!-- VERSION v2.0.7 -->
|
4
4
|
|
5
5
|
<!--
|
6
6
|
ALERT: cannot have root comments, because of https://github.com/metanorma/metanorma/issues/437
|
@@ -76,6 +76,7 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
|
|
76
76
|
<a:documentation>Title(s) of a clause</a:documentation>
|
77
77
|
<element name="title">
|
78
78
|
<a:documentation>Title proper for a clause</a:documentation>
|
79
|
+
<ref name="RequiredId"/>
|
79
80
|
<zeroOrMore>
|
80
81
|
<ref name="TextElement"/>
|
81
82
|
</zeroOrMore>
|
@@ -83,10 +84,19 @@ but to `@anchor`, the user-supplied cross-reference</a:documentation>
|
|
83
84
|
<zeroOrMore>
|
84
85
|
<element name="variant-title">
|
85
86
|
<a:documentation>Alternate title for a clause</a:documentation>
|
87
|
+
<ref name="RequiredId"/>
|
86
88
|
<ref name="TypedTitleString"/>
|
87
89
|
</element>
|
88
90
|
</zeroOrMore>
|
89
91
|
</define>
|
92
|
+
<define name="tname">
|
93
|
+
<element name="name">
|
94
|
+
<ref name="RequiredId"/>
|
95
|
+
<oneOrMore>
|
96
|
+
<ref name="NestedTextElement"/>
|
97
|
+
</oneOrMore>
|
98
|
+
</element>
|
99
|
+
</define>
|
90
100
|
<define name="UlBody">
|
91
101
|
<optional>
|
92
102
|
<ref name="tname">
|
@@ -475,6 +485,7 @@ normative or informative references, some split references into sections organiz
|
|
475
485
|
<!-- exclude figures? -->
|
476
486
|
<define name="dd">
|
477
487
|
<element name="dd">
|
488
|
+
<ref name="OptionalId"/>
|
478
489
|
<zeroOrMore>
|
479
490
|
<!-- exclude figures? -->
|
480
491
|
<ref name="BasicBlock"/>
|
@@ -526,6 +537,7 @@ normative or informative references, some split references into sections organiz
|
|
526
537
|
</choice>
|
527
538
|
</define>
|
528
539
|
<define name="TrAttributes">
|
540
|
+
<ref name="OptionalId"/>
|
529
541
|
<optional>
|
530
542
|
<attribute name="style">
|
531
543
|
<a:documentation>CSS style: only background-color supported</a:documentation>
|
@@ -595,6 +607,7 @@ gives an explicit page orientation</a:documentation>
|
|
595
607
|
</include>
|
596
608
|
<!-- end overrides -->
|
597
609
|
<define name="FnAttributes" combine="interleave">
|
610
|
+
<ref name="RequiredId"/>
|
598
611
|
<optional>
|
599
612
|
<attribute name="hiddenref">
|
600
613
|
<a:documentation>If true, number the footnote as normal, but suppress display of the footnote reference in the document body.
|
@@ -604,6 +617,7 @@ This is done if the footnote reference is already presented in some other form,
|
|
604
617
|
</optional>
|
605
618
|
</define>
|
606
619
|
<define name="TdAttributes" combine="interleave">
|
620
|
+
<ref name="RequiredId"/>
|
607
621
|
<optional>
|
608
622
|
<attribute name="style">
|
609
623
|
<a:documentation>CSS style: only background-color supported</a:documentation>
|
@@ -1821,7 +1835,7 @@ used in document amendments</a:documentation>
|
|
1821
1835
|
</element>
|
1822
1836
|
</define>
|
1823
1837
|
<define name="TermAttributes">
|
1824
|
-
<ref name="
|
1838
|
+
<ref name="RequiredId"/>
|
1825
1839
|
<ref name="LocalizedStringAttributes"/>
|
1826
1840
|
<ref name="BlockAttributes"/>
|
1827
1841
|
</define>
|
@@ -2164,6 +2178,7 @@ used in document amendments</a:documentation>
|
|
2164
2178
|
<define name="termdefinition">
|
2165
2179
|
<a:documentation>The definition of a term applied in the current document</a:documentation>
|
2166
2180
|
<element name="definition">
|
2181
|
+
<ref name="RequiredId"/>
|
2167
2182
|
<optional>
|
2168
2183
|
<attribute name="type">
|
2169
2184
|
<a:documentation>Type of definition, used to differentiate it from other definitions of the same term if present</a:documentation>
|
@@ -2185,6 +2200,7 @@ used in document amendments</a:documentation>
|
|
2185
2200
|
</define>
|
2186
2201
|
<define name="verbaldefinition">
|
2187
2202
|
<element name="verbal-definition">
|
2203
|
+
<ref name="RequiredId"/>
|
2188
2204
|
<oneOrMore>
|
2189
2205
|
<choice>
|
2190
2206
|
<a:documentation>Content of the verbal representation of the term</a:documentation>
|
@@ -2205,6 +2221,7 @@ used in document amendments</a:documentation>
|
|
2205
2221
|
<define name="nonverbalrep">
|
2206
2222
|
<a:documentation>Non-verbal representation of the term</a:documentation>
|
2207
2223
|
<element name="non-verbal-representation">
|
2224
|
+
<ref name="RequiredId"/>
|
2208
2225
|
<oneOrMore>
|
2209
2226
|
<choice>
|
2210
2227
|
<a:documentation>Content of the non-verbal representation of the term</a:documentation>
|
@@ -85,7 +85,7 @@ module Metanorma
|
|
85
85
|
xml_dl.dd
|
86
86
|
return
|
87
87
|
end
|
88
|
-
xml_dl.dd do |xml_dd|
|
88
|
+
xml_dl.dd **dl_attrs(ddefn) do |xml_dd|
|
89
89
|
xml_dd.p { |t| t << ddefn.text } if ddefn.text?
|
90
90
|
xml_dd << ddefn.content if ddefn.blocks?
|
91
91
|
end
|
@@ -122,7 +122,7 @@ module Metanorma
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def list_caption(node, out)
|
125
|
-
|
125
|
+
block_title(node, out)
|
126
126
|
end
|
127
127
|
end
|
128
128
|
end
|
@@ -57,6 +57,7 @@ module Metanorma
|
|
57
57
|
p.process(l)
|
58
58
|
p.pass ? l : convert(l, c)
|
59
59
|
end
|
60
|
+
log(document, lines)
|
60
61
|
::Asciidoctor::PreprocessorReader.new document, lines
|
61
62
|
end
|
62
63
|
|
@@ -65,6 +66,18 @@ module Metanorma
|
|
65
66
|
/^&[A-Za-z]/.match?(s) ? esc.encode(esc.decode(s), :hexadecimal) : s
|
66
67
|
end.join
|
67
68
|
end
|
69
|
+
|
70
|
+
# debugging output of results of all preprocessing,
|
71
|
+
# including include files concatenation and Lutaml/Liquid processing
|
72
|
+
def log(doc, text)
|
73
|
+
source = doc.attr("docfile") || "metanorma"
|
74
|
+
dirname = File.dirname(source)
|
75
|
+
basename = File.basename(source, ".*")
|
76
|
+
fname = File.join(dirname, "#{basename}.asciidoc.log.txt")
|
77
|
+
File.open(fname, "w:UTF-8") do |f|
|
78
|
+
f.write(text.join("\n"))
|
79
|
+
end
|
80
|
+
end
|
68
81
|
end
|
69
82
|
|
70
83
|
class ColumnBreakBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
|
@@ -107,10 +120,14 @@ module Metanorma
|
|
107
120
|
|
108
121
|
def pass_inline_split(text)
|
109
122
|
text.split(PASS_INLINE_MACRO_RX).each.map do |x|
|
110
|
-
PASS_INLINE_MACRO_RX.match?(x) ? x : yield(x)
|
123
|
+
PASS_INLINE_MACRO_RX.match?(x) ? pass_convert(x) : yield(x)
|
111
124
|
end
|
112
125
|
end
|
113
126
|
|
127
|
+
def pass_convert(text)
|
128
|
+
text.sub(/^pass:\[(.+)$/, "pass-format:metanorma[\\1")
|
129
|
+
end
|
130
|
+
|
114
131
|
# InlineLinkRx = %r((^|link:|#{CG_BLANK}|<|[>\(\)\[\];"'])(\\?(?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)\[(|#{CC_ALL}*?[^\\])\]|([^\s\[\]<]*([^\s,.?!\[\]<\)]))))m
|
115
132
|
#
|
116
133
|
InlineLinkRx = %r((^|(?<![-\\])\blink:(?!\+)|\p{Blank}|<|[<>\(\)\[\];"'])((?:https?|file|ftp|irc)://)(?:([^\s\[\]]+)(?:(\[(|.*?[^\\])\])|([^\s\[\]<]*([^\s,.?!\[\]<\)])))))m
|
@@ -185,5 +202,33 @@ module Metanorma
|
|
185
202
|
end.join
|
186
203
|
end
|
187
204
|
end
|
205
|
+
|
206
|
+
# convert pass:[] to pass-format:metanorma[]
|
207
|
+
class PassProtectPreprocessor < LinkProtectPreprocessor
|
208
|
+
def process(document, reader)
|
209
|
+
p = Metanorma::Utils::LineStatus.new
|
210
|
+
lines = reader.lines.map do |t|
|
211
|
+
p.process(t)
|
212
|
+
!p.pass && t.include?("pass:") and t = inlinelink(t)
|
213
|
+
t
|
214
|
+
end
|
215
|
+
::Asciidoctor::PreprocessorReader.new document, lines
|
216
|
+
end
|
217
|
+
|
218
|
+
def pass_inline_split(text)
|
219
|
+
text.split(PASS_INLINE_MACRO_RX).each.map do |x|
|
220
|
+
PASS_INLINE_MACRO_RX.match?(x) ? pass_convert(x) : x
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def pass_convert(text)
|
225
|
+
text.sub(/^pass:\[(.+)$/, "pass-format:metanorma[\\1")
|
226
|
+
end
|
227
|
+
|
228
|
+
def inlinelink(text)
|
229
|
+
/^\[.*\]\s*$/.match?(text) and return text
|
230
|
+
pass_inline_split(text).join
|
231
|
+
end
|
232
|
+
end
|
188
233
|
end
|
189
234
|
end
|
@@ -135,7 +135,7 @@ module Metanorma
|
|
135
135
|
end
|
136
136
|
|
137
137
|
# inject ZWNJ to prevent Asciidoctor from attempting regex substitutions
|
138
|
-
class
|
138
|
+
class PassFormatInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
139
139
|
use_dsl
|
140
140
|
named :"pass-format"
|
141
141
|
parse_content_as :text
|
@@ -143,8 +143,25 @@ module Metanorma
|
|
143
143
|
def process(parent, target, attrs)
|
144
144
|
format = target || "metanorma"
|
145
145
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
146
|
-
|
147
|
-
|
146
|
+
<<~XML
|
147
|
+
<passthrough-inline formats="#{format}">#{xml_process(out)}</passthrough-inline>
|
148
|
+
XML
|
149
|
+
end
|
150
|
+
|
151
|
+
# Split content into XML tags (including XML-escaped instances),
|
152
|
+
# XML escapes, and text segments
|
153
|
+
# Then only apply ZWNJ to punctuation in text segments
|
154
|
+
def xml_process(out)
|
155
|
+
processed_out = ""
|
156
|
+
segments = out.split(/(<[^>]*>|<[^&]*>|&[^;]*;)/)
|
157
|
+
segments.each_with_index do |segment, index|
|
158
|
+
processed_out += if index.even? # Text segment (not a tag or escape)
|
159
|
+
segment.gsub(/([[:punct:]])/, "\\1‌")
|
160
|
+
else # XML tag or escape
|
161
|
+
segment
|
162
|
+
end
|
163
|
+
end
|
164
|
+
processed_out
|
148
165
|
end
|
149
166
|
end
|
150
167
|
|
@@ -14,7 +14,7 @@ module Metanorma
|
|
14
14
|
@biblio = true
|
15
15
|
attrs = attrs.merge(normative: node.attr("normative") || false)
|
16
16
|
xml.references **attr_code(attrs) do |xml_section|
|
17
|
-
xml_section
|
17
|
+
section_title(xml_section, node.title)
|
18
18
|
xml_section << node.content
|
19
19
|
end
|
20
20
|
@biblio = false
|
@@ -36,7 +36,7 @@ module Metanorma
|
|
36
36
|
@norm_ref = true
|
37
37
|
attrs = attrs.merge(normative: node.attr("normative") || true)
|
38
38
|
xml.references **attr_code(attrs) do |xml_section|
|
39
|
-
xml_section
|
39
|
+
section_title(xml_section, node.title)
|
40
40
|
xml_section << node.content
|
41
41
|
end
|
42
42
|
@norm_ref = false
|
@@ -2,8 +2,7 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Base
|
4
4
|
def html_extract_attributes(node)
|
5
|
-
i18nyaml = node
|
6
|
-
i18nyaml &&= File.join(@localdir, i18nyaml)
|
5
|
+
i18nyaml = i18nyaml_path(node)
|
7
6
|
{
|
8
7
|
script: node.attr("script"),
|
9
8
|
bodyfont: node.attr("body-font"),
|
@@ -11,10 +10,10 @@ module Metanorma
|
|
11
10
|
monospacefont: node.attr("monospace-font"),
|
12
11
|
i18nyaml: i18nyaml,
|
13
12
|
scope: node.attr("scope"),
|
14
|
-
htmlstylesheet: node.attr("htmlstylesheet"),
|
15
|
-
htmlstylesheet_override: node.attr("htmlstylesheet-override"),
|
16
|
-
htmlcoverpage: node.attr("htmlcoverpage"),
|
17
|
-
htmlintropage: node.attr("htmlintropage"),
|
13
|
+
htmlstylesheet: node.attr("htmlstylesheet") || node.attr("html-stylesheet"),
|
14
|
+
htmlstylesheet_override: node.attr("htmlstylesheet-override") || node.attr("html-stylesheet-override"),
|
15
|
+
htmlcoverpage: node.attr("htmlcoverpage") || node.attr("htmlcoverpage"),
|
16
|
+
htmlintropage: node.attr("htmlintropage") || node.attr("html-intropage"),
|
18
17
|
scripts: node.attr("scripts"),
|
19
18
|
scripts_override: node.attr("scripts-override"),
|
20
19
|
scripts_pdf: node.attr("scripts-pdf"),
|
@@ -50,8 +49,7 @@ module Metanorma
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def doc_extract_attributes(node)
|
53
|
-
i18nyaml = node
|
54
|
-
i18nyaml &&= File.join(@localdir, i18nyaml)
|
52
|
+
i18nyaml = i18nyaml_path(node)
|
55
53
|
attrs = {
|
56
54
|
script: node.attr("script"),
|
57
55
|
bodyfont: node.attr("body-font"),
|
@@ -59,9 +57,9 @@ module Metanorma
|
|
59
57
|
monospacefont: node.attr("monospace-font"),
|
60
58
|
i18nyaml: i18nyaml,
|
61
59
|
scope: node.attr("scope"),
|
62
|
-
wordstylesheet: node.attr("wordstylesheet"),
|
63
|
-
wordstylesheet_override: node.attr("wordstylesheet-override"),
|
64
|
-
standardstylesheet: node.attr("standardstylesheet"),
|
60
|
+
wordstylesheet: node.attr("wordstylesheet") || node.attr("word-stylesheet"),
|
61
|
+
wordstylesheet_override: node.attr("wordstylesheet-override") || node.attr("word-stylesheet-override"),
|
62
|
+
standardstylesheet: node.attr("standardstylesheet") || node.attr("standard-stylesheet"),
|
65
63
|
header: node.attr("header"),
|
66
64
|
wordcoverpage: node.attr("wordcoverpage"),
|
67
65
|
wordintropage: node.attr("wordintropage"),
|
@@ -96,13 +94,24 @@ module Metanorma
|
|
96
94
|
pdf-allow-assemble-document pdf-allow-edit-annotations
|
97
95
|
pdf-allow-print pdf-allow-print-hq
|
98
96
|
pdf-allow-access-content pdf-encrypt-metadata fonts
|
97
|
+
pdf-stylesheet pdf-stylesheet-override
|
99
98
|
font-license-agreement).each_with_object({}) do |x, m|
|
100
|
-
m[x.delete("-").
|
99
|
+
m[x.delete("-").sub(/override$/, "_override").to_sym] =
|
100
|
+
node.attr(x) || node.attr(x.sub("pdf-", "pdf"))
|
101
101
|
end
|
102
|
-
|
102
|
+
absolute_path_pdf_attributes(pdf_options)
|
103
103
|
pdf_options.merge(fonts_manifest_option(node) || {})
|
104
104
|
end
|
105
105
|
|
106
|
+
def absolute_path_pdf_attributes(pdf_options)
|
107
|
+
%i(pdfstylesheet pdfstylesheet_override).each do |x|
|
108
|
+
pdf_options[x] or next
|
109
|
+
(Pathname.new pdf_options[x]).absolute? or
|
110
|
+
pdf_options[x] =
|
111
|
+
File.join(File.expand_path(@localdir), pdf_options[x])
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
106
115
|
def doc_converter(node)
|
107
116
|
IsoDoc::WordConvert.new(doc_extract_attributes(node))
|
108
117
|
end
|
@@ -85,12 +85,17 @@ module Metanorma
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
+
def section_title(xml, title)
|
89
|
+
title.nil? and return
|
90
|
+
xml.title **attr_code(id_attr(nil)) do |t|
|
91
|
+
t << title
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
88
95
|
def preamble(node)
|
89
96
|
noko do |xml|
|
90
97
|
xml.foreword **attr_code(section_attributes(node)) do |xml_abstract|
|
91
|
-
xml_abstract.title
|
92
|
-
t << (node.blocks[0].title || @i18n.foreword)
|
93
|
-
end
|
98
|
+
section_title(xml_abstract, node.blocks[0].title || @i18n.foreword)
|
94
99
|
xml_abstract << node.content
|
95
100
|
end
|
96
101
|
end
|
@@ -104,7 +109,7 @@ module Metanorma
|
|
104
109
|
|
105
110
|
def indexsect_parse(attrs, xml, node)
|
106
111
|
xml.indexsect **attr_code(attrs) do |xml_section|
|
107
|
-
xml_section
|
112
|
+
section_title(xml_section, node.title)
|
108
113
|
xml_section << node.content
|
109
114
|
end
|
110
115
|
end
|
@@ -131,7 +136,7 @@ module Metanorma
|
|
131
136
|
node.option?("appendix") && support_appendix?(node) and
|
132
137
|
return appendix_parse(attrs, xml, node)
|
133
138
|
xml.send :clause, **attr_code(attrs) do |xml_section|
|
134
|
-
xml_section
|
139
|
+
section_title(xml_section, node.title)
|
135
140
|
xml_section << node.content
|
136
141
|
end
|
137
142
|
end
|
@@ -144,7 +149,7 @@ module Metanorma
|
|
144
149
|
def annex_parse(attrs, xml, node)
|
145
150
|
annex_attrs_preprocess(attrs, node)
|
146
151
|
xml.annex **attr_code(attrs) do |xml_section|
|
147
|
-
xml_section
|
152
|
+
section_title(xml_section, node.title)
|
148
153
|
xml_section << node.content
|
149
154
|
end
|
150
155
|
end
|
@@ -157,35 +162,35 @@ module Metanorma
|
|
157
162
|
attrs[:"inline-header"] = node.option? "inline-header"
|
158
163
|
set_obligation(attrs, node)
|
159
164
|
xml.appendix **attr_code(attrs) do |xml_section|
|
160
|
-
xml_section
|
165
|
+
section_title(xml_section, node.title)
|
161
166
|
xml_section << node.content
|
162
167
|
end
|
163
168
|
end
|
164
169
|
|
165
170
|
def introduction_parse(attrs, xml, node)
|
166
171
|
xml.introduction **attr_code(attrs) do |xml_section|
|
167
|
-
xml_section
|
172
|
+
section_title(xml_section, @i18n.introduction)
|
168
173
|
xml_section << node.content
|
169
174
|
end
|
170
175
|
end
|
171
176
|
|
172
177
|
def foreword_parse(attrs, xml, node)
|
173
178
|
xml.foreword **attr_code(attrs) do |xml_section|
|
174
|
-
xml_section
|
179
|
+
section_title(xml_section, node.title)
|
175
180
|
xml_section << node.content
|
176
181
|
end
|
177
182
|
end
|
178
183
|
|
179
184
|
def acknowledgements_parse(attrs, xml, node)
|
180
185
|
xml.acknowledgements **attr_code(attrs) do |xml_section|
|
181
|
-
xml_section
|
186
|
+
section_title(xml_section, node.title || @i18n.acknowledgements)
|
182
187
|
xml_section << node.content
|
183
188
|
end
|
184
189
|
end
|
185
190
|
|
186
191
|
def executivesummary_parse(attrs, xml, node)
|
187
192
|
xml.executivesummary **attr_code(attrs) do |xml_section|
|
188
|
-
xml_section
|
193
|
+
section_title(xml_section, node.title || @i18n.executivesummary)
|
189
194
|
xml_section << node.content
|
190
195
|
end
|
191
196
|
end
|
@@ -36,11 +36,7 @@ module Metanorma
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def table_name(node, xml_table)
|
39
|
-
|
40
|
-
xml_table.name do |n|
|
41
|
-
n << node.title
|
42
|
-
end
|
43
|
-
end
|
39
|
+
block_title(node, xml_table)
|
44
40
|
end
|
45
41
|
|
46
42
|
def table_cell1(cell)
|
@@ -67,7 +63,7 @@ module Metanorma
|
|
67
63
|
%i(head body foot).reject { |s| node.rows[s].empty? }.each do |s|
|
68
64
|
xml.send "t#{s}" do |xml_tblsec|
|
69
65
|
node.rows[s].each do |row|
|
70
|
-
xml_tblsec.tr do |xml_tr|
|
66
|
+
xml_tblsec.tr **attr_code(id_attr(nil)) do |xml_tr|
|
71
67
|
row.each { |cell| table_cell(cell, xml_tr, s) }
|
72
68
|
end
|
73
69
|
end
|
@@ -24,7 +24,7 @@ module Metanorma
|
|
24
24
|
def symbols_parse(attr, xml, node)
|
25
25
|
node.role == "nonterm" and return nonterm_symbols_parse(attr, xml, node)
|
26
26
|
xml.definitions **attr_code(attr) do |xml_section|
|
27
|
-
xml_section
|
27
|
+
section_title(xml_section, node.title)
|
28
28
|
stash_symbols
|
29
29
|
@definitions = true
|
30
30
|
stash_term_def
|
@@ -98,7 +98,7 @@ module Metanorma
|
|
98
98
|
|
99
99
|
def term_def_parse(attrs, xml, node, _toplevel)
|
100
100
|
xml.terms **attr_code(attrs) do |section|
|
101
|
-
section
|
101
|
+
section_title(section, node.title)
|
102
102
|
(s = node.attr("source")) && s.split(",").each do |s1|
|
103
103
|
section.termdocsource(nil, **attr_code(bibitemid: s1))
|
104
104
|
end
|
@@ -166,7 +166,8 @@ module Metanorma
|
|
166
166
|
|
167
167
|
def termdefinition(node)
|
168
168
|
noko do |xml|
|
169
|
-
xml.definition **attr_code(
|
169
|
+
xml.definition **attr_code(id_attr(nil)
|
170
|
+
.merge(type: node.attr("type"))) do |d|
|
170
171
|
d << node.content
|
171
172
|
end
|
172
173
|
end
|
@@ -39,6 +39,10 @@ module Metanorma
|
|
39
39
|
node["id"] = "_#{UUIDTools::UUID.random_create}"
|
40
40
|
end
|
41
41
|
|
42
|
+
def add_id_text
|
43
|
+
%(id = "_#{UUIDTools::UUID.random_create}")
|
44
|
+
end
|
45
|
+
|
42
46
|
def csv_split(text, delim = ";")
|
43
47
|
Metanorma::Utils::csv_split(@c.decode(text), delim)
|
44
48
|
.map { |x| @c.encode(x, :basic, :hexadecimal) }
|
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.10
|
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-
|
11
|
+
date: 2025-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|