metanorma-standoc 2.6.1 → 2.6.2
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/cleanup.rb +1 -1
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +24 -7
- data/lib/metanorma/standoc/cleanup_section.rb +15 -4
- data/lib/metanorma/standoc/cleanup_section_names.rb +70 -2
- data/lib/metanorma/standoc/converter.rb +1 -0
- data/lib/metanorma/standoc/isodoc.rng +9 -1
- data/lib/metanorma/standoc/macros.rb +9 -0
- data/lib/metanorma/standoc/processor.rb +1 -0
- data/lib/metanorma/standoc/ref_queue.rb +6 -0
- data/lib/metanorma/standoc/render.rb +4 -2
- 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: bd044342634fd4dd1a67955a5f07785ae4762a0f63520e8254efe6e016853b1a
|
4
|
+
data.tar.gz: 89625dee3748cca3301727fc88650b0f916b8d2f60a258a9731ac09783c2465a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9958565ebd72f63b2a17af3f6cc89d5055d36f77ba15f4b80763ca64f3d45368b084e321ef05b0f49655943df029556a1ddd1c9cf27a7466299977b48aee57cc
|
7
|
+
data.tar.gz: 3979efde78ee18714f49a321ce89c51aa2039cc153863d118ddc788d610fae7788134688454bff075a9c95ace5bb097e5b24b169df9877f17a4321632b230b14
|
@@ -45,7 +45,7 @@ module Metanorma
|
|
45
45
|
element_name_cleanup(xmldoc)
|
46
46
|
ref_cleanup(xmldoc) # feeds: bibitem_cleanup
|
47
47
|
note_cleanup(xmldoc)
|
48
|
-
clausebefore_cleanup(xmldoc)
|
48
|
+
clausebefore_cleanup(xmldoc) # feeeds: floatingtitle_cleanup
|
49
49
|
floatingtitle_cleanup(xmldoc)
|
50
50
|
bibitem_cleanup(xmldoc) # feeds: normref_cleanup, biblio_cleanup,
|
51
51
|
# reference_names, bpart_cleanup
|
@@ -86,16 +86,33 @@ module Metanorma
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def termdef_boilerplate_insert(xmldoc, isodoc, once = false)
|
89
|
-
|
90
|
-
f
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
89
|
+
if once
|
90
|
+
f = termdef_boilerplate_insert_location(xmldoc) and
|
91
|
+
termdef_boilerplate_insert1(f, xmldoc, isodoc)
|
92
|
+
else
|
93
|
+
xmldoc.xpath(self.class::TERM_CLAUSE).each do |f|
|
94
|
+
termdef_boilerplate_insert1(f, xmldoc, isodoc)
|
95
|
+
end
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
def termdef_boilerplate_insert_location(xmldoc)
|
100
|
+
f = xmldoc.at(self.class::TERM_CLAUSE)
|
101
|
+
root = xmldoc.at("//sections/terms | //sections/clause[.//terms]")
|
102
|
+
!f || !root and return f || root
|
103
|
+
f.at("./following::terms") and return root
|
104
|
+
f.at("./preceding-sibling::clause") and return root
|
105
|
+
f
|
106
|
+
end
|
107
|
+
|
108
|
+
def termdef_boilerplate_insert1(sect, xmldoc, isodoc)
|
109
|
+
sect.at("./clause[@type = 'boilerplate'] | " \
|
110
|
+
"./note[@type = 'boilerplate']") and return
|
111
|
+
term_defs_boilerplate(sect.at("./title"),
|
112
|
+
xmldoc.xpath(".//termdocsource"),
|
113
|
+
sect.at(".//term"), sect.at(".//p"), isodoc)
|
114
|
+
end
|
115
|
+
|
99
116
|
def boilerplate_cleanup(xmldoc)
|
100
117
|
isodoc = boilerplate_isodoc(xmldoc)
|
101
118
|
termdef_boilerplate_cleanup(xmldoc)
|
@@ -178,8 +178,8 @@ module Metanorma
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def clausebefore_cleanup(xmldoc)
|
181
|
-
preface_clausebefore_cleanup(xmldoc)
|
182
181
|
sections_clausebefore_cleanup(xmldoc)
|
182
|
+
preface_clausebefore_cleanup(xmldoc)
|
183
183
|
end
|
184
184
|
|
185
185
|
def preface_clausebefore_cleanup(xmldoc)
|
@@ -196,10 +196,20 @@ module Metanorma
|
|
196
196
|
end
|
197
197
|
|
198
198
|
def sections_clausebefore_cleanup(xmldoc)
|
199
|
-
|
200
|
-
|
199
|
+
xmldoc.at("//sections") or return
|
201
200
|
ins = insert_before(xmldoc, "//sections")
|
202
|
-
xmldoc.xpath("//sections//*[@beforeclauses = 'true']").each do |x|
|
201
|
+
xmldoc.xpath("//sections//*[@beforeclauses = 'true']").reverse.each do |x|
|
202
|
+
x.delete("beforeclauses")
|
203
|
+
ins.previous = x.remove
|
204
|
+
end
|
205
|
+
endofpreface_clausebefore(xmldoc, ins)
|
206
|
+
end
|
207
|
+
|
208
|
+
# only move clausebefore notes at the very end of preface
|
209
|
+
def endofpreface_clausebefore(xmldoc, ins)
|
210
|
+
xmldoc.xpath("//preface//*[@beforeclauses = 'true']").reverse.each do |x|
|
211
|
+
textafternote = xmldoc.xpath("//preface//*") & x.xpath("./following::*")
|
212
|
+
textafternote.text.strip.empty? or break
|
203
213
|
x.delete("beforeclauses")
|
204
214
|
ins.previous = x.remove
|
205
215
|
end
|
@@ -214,6 +224,7 @@ module Metanorma
|
|
214
224
|
end
|
215
225
|
|
216
226
|
def floatingtitle_cleanup(xmldoc)
|
227
|
+
pop_floating_title(xmldoc) # done again, after endofpreface_clausebefore
|
217
228
|
floating_title_preface2sections(xmldoc)
|
218
229
|
end
|
219
230
|
|
@@ -50,10 +50,30 @@ module Metanorma
|
|
50
50
|
"[not(.//definitions[@type = 'symbols'])]".freeze
|
51
51
|
|
52
52
|
def section_names_terms_cleanup(xml)
|
53
|
-
|
53
|
+
section_names_definitions(xml)
|
54
|
+
section_names_terms1_cleanup(xml)
|
55
|
+
end
|
56
|
+
|
57
|
+
def section_names_definitions(xml)
|
58
|
+
auto_name_definitions(xml) or return
|
59
|
+
replace_title(xml, "//definitions[@type = 'symbols']",
|
60
|
+
@i18n&.symbols)
|
54
61
|
replace_title(xml, "//definitions[@type = 'abbreviated_terms']",
|
55
62
|
@i18n&.abbrev)
|
56
|
-
replace_title(xml, "//definitions[not(@type)]",
|
63
|
+
replace_title(xml, "//definitions[not(@type)]",
|
64
|
+
@i18n&.symbolsabbrev)
|
65
|
+
end
|
66
|
+
|
67
|
+
def auto_name_definitions(xml)
|
68
|
+
xml.xpath("//definitions[@type = 'symbols']").size > 1 and return false
|
69
|
+
xml.xpath("//definitions[@type = 'abbreviated_terms']").size > 1 and
|
70
|
+
return false
|
71
|
+
xml.xpath("//definitions[not(@type)]").size > 1 and return false
|
72
|
+
true
|
73
|
+
end
|
74
|
+
|
75
|
+
def section_names_terms1_cleanup(xml)
|
76
|
+
auto_name_terms(xml) or return
|
57
77
|
replace_title(xml, "//terms#{SYMnoABBR} | //clause[.//terms]#{SYMnoABBR}",
|
58
78
|
@i18n&.termsdefsymbols, true)
|
59
79
|
replace_title(xml, "//terms#{ABBRnoSYM} | //clause[.//terms]#{ABBRnoSYM}",
|
@@ -69,6 +89,54 @@ module Metanorma
|
|
69
89
|
)
|
70
90
|
end
|
71
91
|
|
92
|
+
# do not auto-name terms sections if there are terms subclauses
|
93
|
+
# not covered by the auto titles,
|
94
|
+
# or if more than one title is covered by an auto title
|
95
|
+
def auto_name_terms(xml)
|
96
|
+
n = xml.at("//terms | //clause[.//terms]")
|
97
|
+
out = terms_subclauses(n)
|
98
|
+
.each_with_object({ term: 0, sna: 0, ans: 0, sa: 0, nsa: 0,
|
99
|
+
tsna: 0, tans: 0, tsa: 0, tnsa: 0,
|
100
|
+
termdef: 0, other: 0 }) do |x, m|
|
101
|
+
terms_subclause_type_tally(x, m, n)
|
102
|
+
end
|
103
|
+
out.delete(:parent)
|
104
|
+
!out.values.detect { |x| x > 1 } && out[:other].zero?
|
105
|
+
end
|
106
|
+
|
107
|
+
def terms_subclauses(node)
|
108
|
+
legal = %w(terms definitions clause)
|
109
|
+
[node, node&.elements].compact.flatten
|
110
|
+
.select do |x|
|
111
|
+
legal.include?(x.name) &&
|
112
|
+
!(x.name == "clause" && x["type"] == "boilerplate")
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def terms_subclause_type_tally(node, m, parent)
|
117
|
+
sym = if (node.at(".//term") && !node.at(".//definitions")) ||
|
118
|
+
(node.name == "terms" && !node.at(".//term"))
|
119
|
+
unless m[:parent] == :term # don't count Term > Term twice
|
120
|
+
:term
|
121
|
+
end
|
122
|
+
elsif node.at(".//term") && node.at("./self::*#{SYMnoABBR}") then :tsna
|
123
|
+
elsif node.at(".//term") && node.at("./self::*#{ABBRnoSYM}") then :tans
|
124
|
+
elsif node.at(".//term") && node.at("./self::*#{SYMABBR}") then :tsa
|
125
|
+
elsif node.at(".//term") && node.at("./self::*#{NO_SYMABBR}") then :tnsa
|
126
|
+
elsif node.at("./self::*#{SYMnoABBR}") then :sna
|
127
|
+
elsif node.at("./self::*#{ABBRnoSYM}") then :ans
|
128
|
+
elsif node.at("./self::*#{SYMABBR}") then :sa
|
129
|
+
elsif node.at("./self::*#{NO_SYMABBR}") then :nsa
|
130
|
+
elsif node.name == "definitions" # ignore
|
131
|
+
elsif node == parent && node.at(".//term") &&
|
132
|
+
node.at(".//definitions")
|
133
|
+
:termdef
|
134
|
+
else :other
|
135
|
+
end
|
136
|
+
node == parent and m[:parent] = sym
|
137
|
+
sym and m[sym] += 1
|
138
|
+
end
|
139
|
+
|
72
140
|
SECTION_CONTAINERS = %w(foreword introduction acknowledgements abstract
|
73
141
|
clause clause references terms definitions annex
|
74
142
|
appendix).freeze
|
@@ -63,6 +63,7 @@ module Metanorma
|
|
63
63
|
treeprocessor Metanorma::Standoc::ToDoInlineAdmonitionBlock
|
64
64
|
block Metanorma::Standoc::PlantUMLBlockMacro
|
65
65
|
block Metanorma::Standoc::PseudocodeBlockMacro
|
66
|
+
block_macro Metanorma::Standoc::ColumnBreakBlockMacro
|
66
67
|
end
|
67
68
|
|
68
69
|
include ::Asciidoctor::Converter
|
@@ -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 v1.2.
|
20
|
+
<!-- VERSION v1.2.6 -->
|
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">
|
@@ -1013,6 +1013,14 @@
|
|
1013
1013
|
</oneOrMore>
|
1014
1014
|
</element>
|
1015
1015
|
</define>
|
1016
|
+
<define name="BasicBlock" combine="choice">
|
1017
|
+
<ref name="columnbreak"/>
|
1018
|
+
</define>
|
1019
|
+
<define name="columnbreak">
|
1020
|
+
<element name="columnbreak">
|
1021
|
+
<empty/>
|
1022
|
+
</element>
|
1023
|
+
</define>
|
1016
1024
|
<define name="MultilingualRenderingType">
|
1017
1025
|
<choice>
|
1018
1026
|
<value>common</value>
|
@@ -61,6 +61,15 @@ module Metanorma
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
+
class ColumnBreakBlockMacro < Asciidoctor::Extensions::BlockMacroProcessor
|
65
|
+
use_dsl
|
66
|
+
named :columnbreak
|
67
|
+
|
68
|
+
def process(parent, _reader, _attrs)
|
69
|
+
create_pass_block parent, "<columnbreak/>", {}, subs: nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
64
73
|
# refer https://github.com/asciidoctor/asciidoctor/blob/main/lib/asciidoctor/substitutors.rb
|
65
74
|
# Not using TreeProcessor because that is still too close to
|
66
75
|
# inline expressions being processed on access (e.g. titles)
|
@@ -142,7 +142,12 @@ module Metanorma
|
|
142
142
|
nil
|
143
143
|
end
|
144
144
|
|
145
|
+
def supply_ref_prefix(ret)
|
146
|
+
ret
|
147
|
+
end
|
148
|
+
|
145
149
|
def fetch_ref1(code, year, opts)
|
150
|
+
code = supply_ref_prefix(code)
|
146
151
|
if opts[:localfile]
|
147
152
|
@local_bibdb.get(code, opts[:localfile])
|
148
153
|
else @bibdb&.fetch(code, year, opts)
|
@@ -156,6 +161,7 @@ module Metanorma
|
|
156
161
|
end
|
157
162
|
|
158
163
|
def fetch_ref_async(ref, idx, res)
|
164
|
+
ref[:code] &&= supply_ref_prefix(ref[:code])
|
159
165
|
if unfetchable_ref_code?(ref)
|
160
166
|
res << [ref, idx, nil]
|
161
167
|
idx += 1
|
@@ -91,7 +91,7 @@ module Metanorma
|
|
91
91
|
pdf-allow-print pdf-allow-print-hq
|
92
92
|
pdf-allow-access-content pdf-encrypt-metadata fonts
|
93
93
|
font-license-agreement).each_with_object({}) do |x, m|
|
94
|
-
m[x.gsub(
|
94
|
+
m[x.gsub("-", "").to_i] = node.attr(x)
|
95
95
|
end
|
96
96
|
|
97
97
|
pdf_options.merge(fonts_manifest_option(node) || {})
|
@@ -102,7 +102,9 @@ module Metanorma
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def presentation_xml_converter(node)
|
105
|
-
IsoDoc::PresentationXMLConvert
|
105
|
+
IsoDoc::PresentationXMLConvert
|
106
|
+
.new(html_extract_attributes(node)
|
107
|
+
.merge(output_formats: ::Metanorma::Standoc::Processor.new.output_formats) )
|
106
108
|
end
|
107
109
|
|
108
110
|
def default_fonts(node)
|
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: 2.6.
|
4
|
+
version: 2.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|