isodoc 2.12.1 → 2.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +1 -1
- data/lib/isodoc/convert.rb +0 -21
- data/lib/isodoc/function/blocks.rb +8 -8
- data/lib/isodoc/function/blocks_example_note.rb +46 -23
- data/lib/isodoc/function/inline.rb +31 -8
- data/lib/isodoc/function/lists.rb +4 -4
- data/lib/isodoc/function/references.rb +5 -5
- data/lib/isodoc/function/reqt.rb +2 -2
- data/lib/isodoc/function/section.rb +25 -25
- data/lib/isodoc/function/section_titles.rb +15 -12
- data/lib/isodoc/function/table.rb +1 -1
- data/lib/isodoc/function/terms.rb +17 -14
- data/lib/isodoc/function/to_word_html.rb +5 -0
- data/lib/isodoc/html_function/footnotes.rb +2 -1
- data/lib/isodoc/html_function/html.rb +1 -5
- data/lib/isodoc/init.rb +14 -4
- data/lib/isodoc/metadata.rb +9 -0
- data/lib/isodoc/metadata_contributor.rb +1 -1
- data/lib/isodoc/metadata_date.rb +1 -1
- data/lib/isodoc/presentation_function/autonum.rb +139 -0
- data/lib/isodoc/presentation_function/block.rb +48 -39
- data/lib/isodoc/presentation_function/docid.rb +0 -23
- data/lib/isodoc/presentation_function/erefs.rb +4 -2
- data/lib/isodoc/presentation_function/image.rb +21 -5
- data/lib/isodoc/presentation_function/inline.rb +1 -1
- data/lib/isodoc/presentation_function/reqt.rb +1 -1
- data/lib/isodoc/presentation_function/section.rb +46 -118
- data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
- data/lib/isodoc/presentation_function/terms.rb +3 -4
- data/lib/isodoc/presentation_function/title.rb +107 -0
- data/lib/isodoc/presentation_function/xrefs.rb +17 -10
- data/lib/isodoc/presentation_xml_convert.rb +2 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +7 -35
- data/lib/isodoc/word_function/footnotes.rb +1 -1
- data/lib/isodoc/word_function/lists.rb +12 -10
- data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
- data/lib/isodoc/word_function/postprocess_table.rb +1 -1
- data/lib/isodoc/word_function/table.rb +2 -2
- data/lib/isodoc/xref/xref_anchor.rb +31 -16
- data/lib/isodoc/xref/xref_counter_types.rb +3 -2
- data/lib/isodoc/xref/xref_gen.rb +57 -33
- data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
- data/lib/isodoc/xref/xref_sect_gen.rb +60 -28
- data/lib/isodoc/xref/xref_util.rb +43 -1
- data/lib/isodoc/xref.rb +3 -0
- data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
- data/lib/isodoc-yaml/i18n-de.yaml +9 -9
- data/lib/isodoc-yaml/i18n-en.yaml +9 -9
- data/lib/isodoc-yaml/i18n-es.yaml +9 -9
- data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
- data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
- data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
- data/lib/nokogiri/xml/node.rb +1 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eb3b494f63d18c01a41db1113867423729b62912dc89c002bccf7bd5b5e10e9
|
4
|
+
data.tar.gz: 665fa84ece67866381fa3c71c41a04e57f231de95143fee235f157ffbe61daf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1837352724ea2d81646db5a1f499f19ec1f6c84eace5906cd7ae795e6be9fa156e6de43bfa7ecef4ecc4149e7ec4c30c052e64687b1d5f3d8b2ef1b0dfa292e
|
7
|
+
data.tar.gz: 5996acc46b47b24285d1d696d203a16255a69e67a8c25690213afa41d7fe65b02464e26e4db6516b5b3edf020a5222fc342691f0c13b1861d4a436390ea93655
|
data/isodoc.gemspec
CHANGED
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "mn2pdf", ">= 2.08"
|
38
38
|
spec.add_dependency "mn-requirements", "~> 0.4.0"
|
39
39
|
|
40
|
-
spec.add_dependency "relaton-render", "~> 0.
|
40
|
+
spec.add_dependency "relaton-render", "~> 0.8.0"
|
41
41
|
spec.add_dependency "roman-numerals"
|
42
42
|
spec.add_dependency "rouge", "~> 4.0"
|
43
43
|
spec.add_dependency "thread_safe"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -115,31 +115,10 @@ module IsoDoc
|
|
115
115
|
metadata_init(@lang, @script, @locale, @i18n)
|
116
116
|
xref_init(@lang, @script, self, @i18n,
|
117
117
|
{ locale: @locale, bibrender: @bibrender })
|
118
|
-
docxml = preprocess_xslt(docxml)
|
119
118
|
toc_init(docxml)
|
120
119
|
[docxml, filename, dir]
|
121
120
|
end
|
122
121
|
|
123
|
-
def preprocess_xslt(docxml)
|
124
|
-
sheets = extract_preprocess_xslt(docxml)
|
125
|
-
sheets.each do |x|
|
126
|
-
docxml = Nokogiri::XSLT(x).transform(docxml)
|
127
|
-
end
|
128
|
-
docxml
|
129
|
-
rescue ::Error => e
|
130
|
-
require "debug"
|
131
|
-
binding.b
|
132
|
-
end
|
133
|
-
|
134
|
-
def extract_preprocess_xslt(docxml)
|
135
|
-
docxml.xpath(ns("//metanorma-extension/render/preprocess-xslt"))
|
136
|
-
.each_with_object([]) do |x, m|
|
137
|
-
formats = x["format"]&.split(",") || []
|
138
|
-
!formats.empty? && !formats.include?(@format.to_s) and next
|
139
|
-
m << x.children.to_xml
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
122
|
def convert_i18n_init(docxml)
|
144
123
|
convert_i18n_init1(docxml)
|
145
124
|
i18n_init(@lang, @script, @locale)
|
@@ -25,9 +25,9 @@ module IsoDoc
|
|
25
25
|
def figure_parse1(node, out)
|
26
26
|
out.div **figure_attrs(node) do |div|
|
27
27
|
node.children.each do |n|
|
28
|
-
parse(n, div) unless n.name == "name"
|
28
|
+
parse(n, div) unless n.name == "fmt-name"
|
29
29
|
end
|
30
|
-
figure_name_parse(node, div, node.at(ns("./name")))
|
30
|
+
figure_name_parse(node, div, node.at(ns("./fmt-name")))
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
@@ -37,9 +37,9 @@ module IsoDoc
|
|
37
37
|
|
38
38
|
def pseudocode_parse(node, out)
|
39
39
|
@in_figure = true
|
40
|
-
name = node.at(ns("./name"))
|
40
|
+
name = node.at(ns("./fmt-name"))
|
41
41
|
out.div **pseudocode_attrs(node) do |div|
|
42
|
-
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
42
|
+
node.children.each { |n| parse(n, div) unless n.name == "fmt-name" }
|
43
43
|
sourcecode_name_parse(node, div, name)
|
44
44
|
end
|
45
45
|
@in_figure = false
|
@@ -57,7 +57,7 @@ module IsoDoc
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def sourcecode_parse(node, out)
|
60
|
-
name = node.at(ns("./name"))
|
60
|
+
name = node.at(ns("./fmt-name"))
|
61
61
|
out.p **sourcecode_attrs(node) do |div|
|
62
62
|
sourcecode_parse1(node, div)
|
63
63
|
end
|
@@ -71,7 +71,7 @@ module IsoDoc
|
|
71
71
|
node.at("./ancestor::xmlns:table[@class = 'rouge-line-table']") and
|
72
72
|
@sourcecode = "table"
|
73
73
|
node.children.each do |n|
|
74
|
-
%w(name dl).include?(n.name) and next
|
74
|
+
%w(fmt-name dl).include?(n.name) and next
|
75
75
|
parse(n, div)
|
76
76
|
end
|
77
77
|
@sourcecode = false
|
@@ -93,7 +93,7 @@ module IsoDoc
|
|
93
93
|
out.div **attr_code(class: "formula") do |div|
|
94
94
|
div.p do |_p|
|
95
95
|
parse(node.at(ns("./stem")), div)
|
96
|
-
if lbl = node&.at(ns("./name"))&.text
|
96
|
+
if lbl = node&.at(ns("./fmt-name"))&.text
|
97
97
|
insert_tab(div, 1)
|
98
98
|
div << lbl
|
99
99
|
end
|
@@ -109,7 +109,7 @@ module IsoDoc
|
|
109
109
|
out.div **formula_attrs(node) do |div|
|
110
110
|
formula_parse1(node, div)
|
111
111
|
node.children.each do |n|
|
112
|
-
%w(stem name).include? n.name and next
|
112
|
+
%w(stem fmt-name).include? n.name and next
|
113
113
|
parse(n, div)
|
114
114
|
end
|
115
115
|
end
|
@@ -19,9 +19,9 @@ module IsoDoc
|
|
19
19
|
# used if we are boxing examples
|
20
20
|
def example_div_parse(node, out)
|
21
21
|
out.div **example_div_attr(node) do |div|
|
22
|
-
example_label(node, div, node.at(ns("./name")))
|
22
|
+
example_label(node, div, node.at(ns("./fmt-name")))
|
23
23
|
node.children.each do |n|
|
24
|
-
parse(n, div) unless n.name == "name"
|
24
|
+
parse(n, div) unless n.name == "fmt-name"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -39,10 +39,12 @@ module IsoDoc
|
|
39
39
|
out.table **example_table_attr(node) do |t|
|
40
40
|
t.tr do |tr|
|
41
41
|
tr.td **EXAMPLE_TBL_ATTR do |td|
|
42
|
-
example_label(node, td, node.at(ns("./name")))
|
42
|
+
example_label(node, td, node.at(ns("./fmt-name")))
|
43
43
|
end
|
44
44
|
tr.td **EXAMPLE_TD_ATTR do |td|
|
45
|
-
node.children.each
|
45
|
+
node.children.each do |n|
|
46
|
+
parse(n, td) unless n.name == "fmt-name"
|
47
|
+
end
|
46
48
|
end
|
47
49
|
end
|
48
50
|
end
|
@@ -52,26 +54,45 @@ module IsoDoc
|
|
52
54
|
example_div_parse(node, out)
|
53
55
|
end
|
54
56
|
|
57
|
+
def block_body_first_elem(node)
|
58
|
+
node.elements.each do |n|
|
59
|
+
%w(title fmt-title fmt-xref-label fmt-name name)
|
60
|
+
.include?(n.name) and next
|
61
|
+
return n
|
62
|
+
end
|
63
|
+
nil
|
64
|
+
end
|
65
|
+
|
66
|
+
def starts_with_para?(node)
|
67
|
+
block_body_first_elem(node)&.name == "p"
|
68
|
+
end
|
69
|
+
|
70
|
+
def note_p_class
|
71
|
+
nil
|
72
|
+
end
|
73
|
+
|
55
74
|
def note_p_parse(node, div)
|
56
|
-
name = node.at(ns("./name"))
|
57
|
-
|
75
|
+
name = node.at(ns("./fmt-name"))
|
76
|
+
para = node.at(ns("./p"))
|
77
|
+
div.p **attr_code(class: note_p_class) do |p|
|
58
78
|
name and p.span class: "note_label" do |s|
|
59
79
|
name.children.each { |n| parse(n, s) }
|
60
80
|
end
|
61
|
-
insert_tab(p, 1)
|
62
|
-
|
81
|
+
#insert_tab(p, 1) # TODO to Presentation XML
|
82
|
+
children_parse(para, p)
|
63
83
|
end
|
64
|
-
|
84
|
+
para.xpath("./following-sibling::*").each { |n| parse(n, div) }
|
65
85
|
end
|
66
86
|
|
67
87
|
def note_parse1(node, div)
|
68
|
-
name = node.at(ns("./name")) and
|
69
|
-
p
|
70
|
-
|
88
|
+
name = node.at(ns("./fmt-name")) and
|
89
|
+
div.p **attr_code(class: note_p_class) do |p|
|
90
|
+
p.span class: "note_label" do |s|
|
91
|
+
name.remove.children.each { |n| parse(n, s) }
|
92
|
+
end
|
93
|
+
#insert_tab(p, 1) # TODO to Presentation XML
|
71
94
|
end
|
72
|
-
|
73
|
-
end
|
74
|
-
node.children.each { |n| parse(n, div) }
|
95
|
+
children_parse(node, div)
|
75
96
|
end
|
76
97
|
|
77
98
|
def keep_style(node)
|
@@ -94,7 +115,7 @@ module IsoDoc
|
|
94
115
|
def note_parse(node, out)
|
95
116
|
@note = true
|
96
117
|
out.div **note_attrs(node) do |div|
|
97
|
-
if node
|
118
|
+
if starts_with_para?(node)
|
98
119
|
note_p_parse(node, div)
|
99
120
|
else
|
100
121
|
note_parse1(node, div)
|
@@ -105,7 +126,7 @@ module IsoDoc
|
|
105
126
|
|
106
127
|
def admonition_name_parse(_node, div, name)
|
107
128
|
div.p class: "AdmonitionTitle", style: "text-align:center;" do |p|
|
108
|
-
name
|
129
|
+
children_parse(name, p)
|
109
130
|
end
|
110
131
|
end
|
111
132
|
|
@@ -114,7 +135,7 @@ module IsoDoc
|
|
114
135
|
end
|
115
136
|
|
116
137
|
def admonition_name(node, _type)
|
117
|
-
node&.at(ns("./name"))
|
138
|
+
node&.at(ns("./fmt-name"))
|
118
139
|
end
|
119
140
|
|
120
141
|
def admonition_attrs(node)
|
@@ -124,7 +145,7 @@ module IsoDoc
|
|
124
145
|
|
125
146
|
def admonition_parse(node, out)
|
126
147
|
out.div **admonition_attrs(node) do |div|
|
127
|
-
if node
|
148
|
+
if starts_with_para?(node)
|
128
149
|
admonition_p_parse(node, div)
|
129
150
|
else
|
130
151
|
admonition_parse1(node, div)
|
@@ -139,14 +160,16 @@ module IsoDoc
|
|
139
160
|
|
140
161
|
# code to allow name and first paragraph to be rendered in same block
|
141
162
|
def admonition_name_in_first_para(node, div)
|
163
|
+
name = node.at(ns("./fmt-name"))
|
164
|
+
para = node.at(ns("./p"))
|
142
165
|
div.p do |p|
|
143
166
|
if name = admonition_name(node, node["type"])&.remove
|
144
167
|
name.children.each { |n| parse(n, p) }
|
145
|
-
admonition_name_para_delim(p)
|
168
|
+
admonition_name_para_delim(p) # TODO to Presentation XML
|
146
169
|
end
|
147
|
-
|
170
|
+
para.children.each { |n| parse(n, p) }
|
148
171
|
end
|
149
|
-
|
172
|
+
para.xpath("./following-sibling::*").each { |n| parse(n, div) }
|
150
173
|
end
|
151
174
|
|
152
175
|
def admonition_name_para_delim(para)
|
@@ -158,7 +181,7 @@ module IsoDoc
|
|
158
181
|
if name
|
159
182
|
admonition_name_parse(node, div, name)
|
160
183
|
end
|
161
|
-
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
184
|
+
node.children.each { |n| parse(n, div) unless n.name == "fmt-name" }
|
162
185
|
end
|
163
186
|
end
|
164
187
|
end
|
@@ -17,13 +17,20 @@ module IsoDoc
|
|
17
17
|
|
18
18
|
def location_parse(node, out); end
|
19
19
|
|
20
|
+
# Presentation XML classes which we need not pass on to HTML or DOC
|
21
|
+
SPAN_UNWRAP_CLASSES =
|
22
|
+
%w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
|
23
|
+
fmt-element-name fmt-conn fmt-comma fmt-enum-comma fmt-obligation
|
24
|
+
fmt-xref-container].freeze
|
25
|
+
|
20
26
|
def span_parse(node, out)
|
21
|
-
|
27
|
+
klass = node["style"] || node["class"]
|
28
|
+
if klass && !SPAN_UNWRAP_CLASSES.include?(klass)
|
22
29
|
out.span **attr_code(style: node["style"],
|
23
30
|
class: node["class"]) do |s|
|
24
|
-
node
|
31
|
+
children_parse(node, s)
|
25
32
|
end
|
26
|
-
else node
|
33
|
+
else children_parse(node, out)
|
27
34
|
end
|
28
35
|
end
|
29
36
|
|
@@ -48,9 +55,8 @@ module IsoDoc
|
|
48
55
|
end
|
49
56
|
|
50
57
|
def suffix_url(url)
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
url.nil? || %r{^https?://|^#}.match?(url) and return url
|
59
|
+
File.extname(url).empty? or return url
|
54
60
|
url.sub(/#{File.extname(url)}$/, ".html")
|
55
61
|
end
|
56
62
|
|
@@ -136,8 +142,7 @@ module IsoDoc
|
|
136
142
|
end
|
137
143
|
|
138
144
|
def text_parse(node, out)
|
139
|
-
|
140
|
-
|
145
|
+
node.nil? || node.text.nil? and return
|
141
146
|
text = node.to_s
|
142
147
|
@sourcecode == "pre" and
|
143
148
|
text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/> ")
|
@@ -184,8 +189,26 @@ module IsoDoc
|
|
184
189
|
end
|
185
190
|
|
186
191
|
def author_parse(node, out)
|
192
|
+
children_parse(node, out)
|
193
|
+
end
|
194
|
+
|
195
|
+
def semx_parse(node, out)
|
196
|
+
children_parse(node, out)
|
197
|
+
end
|
198
|
+
|
199
|
+
def children_parse(node, out)
|
187
200
|
node.children.each { |n| parse(n, out) }
|
188
201
|
end
|
202
|
+
|
203
|
+
def xref_label_parse(node, out); end
|
204
|
+
|
205
|
+
def name_parse(node, out); end
|
206
|
+
|
207
|
+
def floating_title_parse(node, out); end
|
208
|
+
|
209
|
+
def fmt_name_parse(node, out)
|
210
|
+
children_parse(node, out)
|
211
|
+
end
|
189
212
|
end
|
190
213
|
end
|
191
214
|
end
|
@@ -2,7 +2,7 @@ module IsoDoc
|
|
2
2
|
module Function
|
3
3
|
module Lists
|
4
4
|
def list_title_parse(node, out)
|
5
|
-
name = node.at(ns("./name")) or return
|
5
|
+
name = node.at(ns("./fmt-name")) or return
|
6
6
|
out.p class: "ListTitle" do |p|
|
7
7
|
name.children&.each { |n| parse(n, p) }
|
8
8
|
end
|
@@ -16,7 +16,7 @@ module IsoDoc
|
|
16
16
|
out.div **attr_code(class: "ul_wrap") do |div|
|
17
17
|
list_title_parse(node, div)
|
18
18
|
div.ul **attr_code(ul_attrs(node)) do |ul|
|
19
|
-
node.children.each { |n| n.name == "name" or parse(n, ul) }
|
19
|
+
node.children.each { |n| n.name == "fmt-name" or parse(n, ul) }
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -57,7 +57,7 @@ module IsoDoc
|
|
57
57
|
out.div **attr_code(class: "ol_wrap") do |div|
|
58
58
|
list_title_parse(node, div)
|
59
59
|
div.ol **attr_code(ol_attrs(node)) do |ol|
|
60
|
-
node.children.each { |n| n.name == "name" or parse(n, ol) }
|
60
|
+
node.children.each { |n| n.name == "fmt-name" or parse(n, ol) }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
@@ -106,7 +106,7 @@ module IsoDoc
|
|
106
106
|
end
|
107
107
|
|
108
108
|
def dl_parse_notes(node, out)
|
109
|
-
node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
|
109
|
+
node.elements.reject { |n| dt_dd?(n) || n.name == "fmt-name" }
|
110
110
|
.each { |n| parse(n, out) }
|
111
111
|
end
|
112
112
|
|
@@ -26,7 +26,7 @@ module IsoDoc
|
|
26
26
|
i += 1
|
27
27
|
bibitem_entry(div, b, i, biblio)
|
28
28
|
else
|
29
|
-
parse(b, div) unless %w(title).include? b.name
|
29
|
+
parse(b, div) unless %w(fmt-title).include? b.name
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -41,9 +41,9 @@ module IsoDoc
|
|
41
41
|
def norm_ref(node, out)
|
42
42
|
node["hidden"] != "true" or return
|
43
43
|
out.div do |div|
|
44
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
44
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
45
45
|
if node.name == "clause"
|
46
|
-
node.elements.each { |e| parse(e, div) unless e.name == "title" }
|
46
|
+
node.elements.each { |e| parse(e, div) unless e.name == "fmt-title" }
|
47
47
|
else biblio_list(node, div, false)
|
48
48
|
end
|
49
49
|
end
|
@@ -60,7 +60,7 @@ module IsoDoc
|
|
60
60
|
page_break(out)
|
61
61
|
out.div do |div|
|
62
62
|
div.h1 class: "Section3" do |h1|
|
63
|
-
node.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
|
63
|
+
node.at(ns("./fmt-title"))&.children&.each { |c2| parse(c2, h1) }
|
64
64
|
end
|
65
65
|
biblio_list(node, div, true)
|
66
66
|
end
|
@@ -69,7 +69,7 @@ module IsoDoc
|
|
69
69
|
def bibliography_parse(node, out)
|
70
70
|
node["hidden"] != true or return
|
71
71
|
out.div do |div|
|
72
|
-
clause_parse_title(node, div, node.at(ns("./title")), out,
|
72
|
+
clause_parse_title(node, div, node.at(ns("./fmt-title")), out,
|
73
73
|
{ class: "Section3" })
|
74
74
|
biblio_list(node, div, true)
|
75
75
|
end
|
data/lib/isodoc/function/reqt.rb
CHANGED
@@ -20,9 +20,9 @@ module IsoDoc
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def recommendation_parse1(node, out)
|
23
|
-
recommendation_name(node.at(ns("./name")), out)
|
23
|
+
recommendation_name(node.at(ns("./fmt-name")), out)
|
24
24
|
node.children.each do |n|
|
25
|
-
parse(n, out) unless n.name == "name"
|
25
|
+
parse(n, out) unless n.name == "fmt-name"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -10,8 +10,8 @@ module IsoDoc
|
|
10
10
|
# used for subclauses
|
11
11
|
def clause_parse(node, out)
|
12
12
|
out.div **attr_code(clause_attrs(node)) do |div|
|
13
|
-
clause_parse_title(node, div, node.at(ns("./title")), out)
|
14
|
-
node.children.reject { |c1| c1.name == "title" }.each do |c1|
|
13
|
+
clause_parse_title(node, div, node.at(ns("./fmt-title")), out)
|
14
|
+
node.children.reject { |c1| c1.name == "fmt-title" }.each do |c1|
|
15
15
|
parse(c1, div)
|
16
16
|
end
|
17
17
|
end
|
@@ -19,8 +19,8 @@ module IsoDoc
|
|
19
19
|
|
20
20
|
def clause(node, out)
|
21
21
|
out.div **attr_code(clause_attrs(node)) do |s|
|
22
|
-
clause_name(node, node.at(ns("./title")), s, nil)
|
23
|
-
node.elements.reject { |c1| c1.name == "title" }.each do |c1|
|
22
|
+
clause_name(node, node.at(ns("./fmt-title")), s, nil)
|
23
|
+
node.elements.reject { |c1| c1.name == "fmt-title" }.each do |c1|
|
24
24
|
parse(c1, s)
|
25
25
|
end
|
26
26
|
end
|
@@ -34,7 +34,7 @@ module IsoDoc
|
|
34
34
|
page_break(out)
|
35
35
|
out.div **attr_code(annex_attrs(node)) do |s|
|
36
36
|
node.elements.each do |c1|
|
37
|
-
if c1.name == "title" then annex_name(node, c1, s)
|
37
|
+
if c1.name == "fmt-title" then annex_name(node, c1, s)
|
38
38
|
else parse(c1, s)
|
39
39
|
end
|
40
40
|
end
|
@@ -47,9 +47,9 @@ module IsoDoc
|
|
47
47
|
|
48
48
|
def scope(node, out)
|
49
49
|
out.div **attr_code(id: node["id"]) do |div|
|
50
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
50
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
51
51
|
node.elements.each do |e|
|
52
|
-
parse(e, div) unless e.name == "title"
|
52
|
+
parse(e, div) unless e.name == "fmt-title"
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -59,9 +59,9 @@ module IsoDoc
|
|
59
59
|
|
60
60
|
def terms_defs(node, out)
|
61
61
|
out.div **attr_code(id: node["id"]) do |div|
|
62
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
62
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
63
63
|
node.elements.each do |e|
|
64
|
-
parse(e, div) unless %w{title source}.include? e.name
|
64
|
+
parse(e, div) unless %w{fmt-title source}.include? e.name
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -73,9 +73,9 @@ module IsoDoc
|
|
73
73
|
|
74
74
|
def symbols_abbrevs(node, out)
|
75
75
|
out.div **attr_code(id: node["id"], class: "Symbols") do |div|
|
76
|
-
clause_name(node, node.at(ns("./title")), div, nil)
|
76
|
+
clause_name(node, node.at(ns("./fmt-title")), div, nil)
|
77
77
|
node.elements.each do |e|
|
78
|
-
parse(e, div) unless e.name == "title"
|
78
|
+
parse(e, div) unless e.name == "fmt-title"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -88,10 +88,10 @@ module IsoDoc
|
|
88
88
|
def introduction(clause, out)
|
89
89
|
page_break(out)
|
90
90
|
out.div class: "Section3", id: clause["id"] do |div|
|
91
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
91
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
92
92
|
{ class: "IntroTitle" })
|
93
93
|
clause.elements.each do |e|
|
94
|
-
parse(e, div) unless e.name == "title"
|
94
|
+
parse(e, div) unless e.name == "fmt-title"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -99,9 +99,9 @@ module IsoDoc
|
|
99
99
|
def foreword(clause, out)
|
100
100
|
page_break(out)
|
101
101
|
out.div **attr_code(id: clause["id"]) do |s|
|
102
|
-
clause_name(clause, clause.at(ns("./title")), s,
|
102
|
+
clause_name(clause, clause.at(ns("./fmt-title")), s,
|
103
103
|
{ class: "ForewordTitle" })
|
104
|
-
clause.elements.each { |e| parse(e, s) unless e.name == "title" }
|
104
|
+
clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -109,9 +109,9 @@ module IsoDoc
|
|
109
109
|
title_attr = { class: "IntroTitle" }
|
110
110
|
page_break(out)
|
111
111
|
out.div class: "Section3", id: clause["id"] do |div|
|
112
|
-
clause_name(clause, clause.at(ns("./title")), div, title_attr)
|
112
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div, title_attr)
|
113
113
|
clause.elements.each do |e|
|
114
|
-
parse(e, div) unless e.name == "title"
|
114
|
+
parse(e, div) unless e.name == "fmt-title"
|
115
115
|
end
|
116
116
|
end
|
117
117
|
end
|
@@ -119,9 +119,9 @@ module IsoDoc
|
|
119
119
|
def abstract(clause, out)
|
120
120
|
page_break(out)
|
121
121
|
out.div **attr_code(id: clause["id"]) do |s|
|
122
|
-
clause_name(clause, clause.at(ns("./title")), s,
|
122
|
+
clause_name(clause, clause.at(ns("./fmt-title")), s,
|
123
123
|
{ class: "AbstractTitle" })
|
124
|
-
clause.elements.each { |e| parse(e, s) unless e.name == "title" }
|
124
|
+
clause.elements.each { |e| parse(e, s) unless e.name == "fmt-title" }
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -141,10 +141,10 @@ module IsoDoc
|
|
141
141
|
def preface_normal(clause, out)
|
142
142
|
page_break(out)
|
143
143
|
out.div **attr_code(preface_attrs(clause)) do |div|
|
144
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
144
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
145
145
|
{ class: "IntroTitle" })
|
146
146
|
clause.elements.each do |e|
|
147
|
-
parse(e, div) unless e.name == "title"
|
147
|
+
parse(e, div) unless e.name == "fmt-title"
|
148
148
|
end
|
149
149
|
end
|
150
150
|
end
|
@@ -153,10 +153,10 @@ module IsoDoc
|
|
153
153
|
@bare and return
|
154
154
|
page_break(out)
|
155
155
|
out.div **attr_code(preface_attrs(clause)) do |div|
|
156
|
-
clause_name(clause, clause.at(ns("./title")), div,
|
156
|
+
clause_name(clause, clause.at(ns("./fmt-title")), div,
|
157
157
|
{ class: "IntroTitle" })
|
158
158
|
clause.elements.each do |e|
|
159
|
-
parse(e, div) unless e.name == "title"
|
159
|
+
parse(e, div) unless e.name == "fmt-title"
|
160
160
|
end
|
161
161
|
end
|
162
162
|
end
|
@@ -165,10 +165,10 @@ module IsoDoc
|
|
165
165
|
@seen_colophon or page_break(out)
|
166
166
|
@seen_colophon = true
|
167
167
|
out.div class: "Section3", id: node["id"] do |div|
|
168
|
-
clause_name(node, node.at(ns("./title")), div,
|
168
|
+
clause_name(node, node.at(ns("./fmt-title")), div,
|
169
169
|
{ class: "IntroTitle" })
|
170
170
|
node.elements.each do |e|
|
171
|
-
parse(e, div) unless e.name == "title"
|
171
|
+
parse(e, div) unless e.name == "fmt-title"
|
172
172
|
end
|
173
173
|
end
|
174
174
|
end
|
@@ -18,18 +18,24 @@ module IsoDoc
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def sections_names
|
22
|
+
%w[clause annex terms references definitions
|
23
|
+
acknowledgements introduction abstract foreword appendix]
|
24
|
+
end
|
25
|
+
|
21
26
|
def freestanding_title(node, out)
|
22
|
-
|
23
|
-
|
24
|
-
|
27
|
+
# node.parent.at(ns("./fmt-title[@source = '#{node['id']}']")) and
|
28
|
+
# return # this title is already being rendered as fmt-title
|
29
|
+
# For testing convenience, let's just go by parent
|
30
|
+
sections_names.include?(node.parent.name) and return
|
31
|
+
parents = node.ancestors(sections_names.join(", "))
|
25
32
|
clause_parse_title(parents.empty? ? node : parents.first,
|
26
33
|
out, node, out)
|
27
34
|
end
|
28
35
|
|
29
36
|
# used for subclauses
|
30
37
|
def clause_parse_title(node, div, title, out, header_class = {})
|
31
|
-
|
32
|
-
|
38
|
+
title.nil? and return
|
33
39
|
if node["inline-header"] == "true"
|
34
40
|
inline_header_title(out, node, title)
|
35
41
|
else
|
@@ -46,9 +52,7 @@ module IsoDoc
|
|
46
52
|
end
|
47
53
|
|
48
54
|
def clause_title_depth(node, title)
|
49
|
-
depth = node.ancestors("
|
50
|
-
"definitions, acknowledgements, introduction, " \
|
51
|
-
"foreword").size + 1
|
55
|
+
depth = node.ancestors(sections_names.join(", ")).size + 1
|
52
56
|
depth = title["depth"] if title && title["depth"]
|
53
57
|
depth
|
54
58
|
end
|
@@ -67,8 +71,8 @@ module IsoDoc
|
|
67
71
|
header_class = {} if header_class.nil?
|
68
72
|
div.h1 **attr_code(header_class) do |h1|
|
69
73
|
if title.is_a?(String) then h1 << title
|
70
|
-
|
71
|
-
title
|
74
|
+
elsif title
|
75
|
+
children_parse(title, h1)
|
72
76
|
clause_parse_subtitle(title, h1)
|
73
77
|
end
|
74
78
|
end
|
@@ -76,8 +80,7 @@ module IsoDoc
|
|
76
80
|
end
|
77
81
|
|
78
82
|
def annex_name(_annex, name, div)
|
79
|
-
|
80
|
-
|
83
|
+
name.nil? and return
|
81
84
|
div.h1 class: "Annex" do |t|
|
82
85
|
name.children.each { |c2| parse(c2, t) }
|
83
86
|
clause_parse_subtitle(name, t)
|
@@ -2,7 +2,7 @@ module IsoDoc
|
|
2
2
|
module Function
|
3
3
|
module Table
|
4
4
|
def table_title_parse(node, out)
|
5
|
-
name = node.at(ns("./name")) or return
|
5
|
+
name = node.at(ns("./fmt-name")) or return
|
6
6
|
out.p class: "TableTitle", style: "text-align:center;" do |p|
|
7
7
|
name&.children&.each { |n| parse(n, p) }
|
8
8
|
end
|