isodoc 1.7.3.1 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,204 +1,209 @@
1
- module IsoDoc::Function
2
- module References
3
- # This is highly specific to ISO, but it's not a bad precedent for
4
- # references anyway; keeping here instead of in IsoDoc::Iso for now
5
- def docid_l10n(text)
6
- return text if text.nil?
7
-
8
- text.gsub(/All Parts/i, @i18n.all_parts.downcase) if @i18n.all_parts
9
- text
10
- end
1
+ module IsoDoc
2
+ module Function
3
+ module References
4
+ # This is highly specific to ISO, but it's not a bad precedent for
5
+ # references anyway; keeping here instead of in IsoDoc::Iso for now
6
+ def docid_l10n(text)
7
+ return text if text.nil?
8
+
9
+ text.gsub(/All Parts/i, @i18n.all_parts.downcase) if @i18n.all_parts
10
+ text
11
+ end
11
12
 
12
- # TODO generate formatted ref if not present
13
- def nonstd_bibitem(list, bib, ordinal, biblio)
14
- list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
15
- ids = bibitem_ref_code(bib)
16
- identifiers = render_identifier(ids)
17
- if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
18
- else
19
- ref << (identifiers[0] || identifiers[1]).to_s
20
- ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
13
+ # TODO generate formatted ref if not present
14
+ def nonstd_bibitem(list, bib, ordinal, biblio)
15
+ list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
16
+ ids = bibitem_ref_code(bib)
17
+ identifiers = render_identifier(ids)
18
+ if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
19
+ else
20
+ ref << (identifiers[0] || identifiers[1]).to_s
21
+ ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
22
+ end
23
+ ref << ", " unless biblio && !identifiers[1]
24
+ reference_format(bib, ref)
21
25
  end
22
- ref << ", " unless biblio && !identifiers[1]
23
- reference_format(bib, ref)
24
26
  end
25
- end
26
27
 
27
- def std_bibitem_entry(list, bib, ordinal, biblio)
28
- list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
29
- identifiers = render_identifier(bibitem_ref_code(bib))
30
- if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
31
- else
32
- ref << (identifiers[0] || identifiers[1]).to_s
33
- ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
28
+ def std_bibitem_entry(list, bib, ordinal, biblio)
29
+ list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
30
+ identifiers = render_identifier(bibitem_ref_code(bib))
31
+ if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
32
+ else
33
+ ref << (identifiers[0] || identifiers[1]).to_s
34
+ ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
35
+ end
36
+ date_note_process(bib, ref)
37
+ ref << ", " unless biblio && !identifiers[1]
38
+ reference_format(bib, ref)
34
39
  end
35
- date_note_process(bib, ref)
36
- ref << ", " unless biblio && !identifiers[1]
37
- reference_format(bib, ref)
38
40
  end
39
- end
40
41
 
41
- # if t is just a number, only use that ([1] Non-Standard)
42
- # else, use both ordinal, as prefix, and t
43
- def ref_entry_code(r, ordinal, t, _id)
44
- prefix_bracketed_ref(r, t[0] || "[#{ordinal}]")
45
- t[1] and r << (t[1]).to_s
46
- end
42
+ # if ids is just a number, only use that ([1] Non-Standard)
43
+ # else, use both ordinal, as prefix, and ids
44
+ def ref_entry_code(ref, ordinal, ids, _id)
45
+ prefix_bracketed_ref(ref, ids[0] || "[#{ordinal}]")
46
+ ids[1] and ref << (ids[1]).to_s
47
+ end
47
48
 
48
- def pref_ref_code(bib)
49
- bib.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
50
- "or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"))
51
- end
49
+ def pref_ref_code(bib)
50
+ bib.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
51
+ "or @type = 'ISSN' or @type = 'ISBN' or "\
52
+ "@type = 'rfc-anchor')]"))
53
+ end
52
54
 
53
- # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
54
- def bibitem_ref_code(bib)
55
- id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
56
- id1 = pref_ref_code(bib)
57
- id2 = bib.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
58
- "@type = 'ISBN']"))
59
- return [id, id1, id2] if id || id1 || id2
60
-
61
- id = Nokogiri::XML::Node.new("docidentifier", bib.document)
62
- id << "(NO ID)"
63
- [nil, id, nil]
64
- end
55
+ # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
56
+ def bibitem_ref_code(bib)
57
+ id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
58
+ id1 = pref_ref_code(bib)
59
+ id2 = bib.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or "\
60
+ "@type = 'ISBN']"))
61
+ return [id, id1, id2] if id || id1 || id2
62
+
63
+ id = Nokogiri::XML::Node.new("docidentifier", bib.document)
64
+ id << "(NO ID)"
65
+ [nil, id, nil]
66
+ end
65
67
 
66
- def bracket_if_num(num)
67
- return nil if num.nil?
68
+ def bracket_if_num(num)
69
+ return nil if num.nil?
68
70
 
69
- num = num.text.sub(/^\[/, "").sub(/\]$/, "")
70
- return "[#{num}]" if /^\d+$/.match?(num)
71
+ num = num.text.sub(/^\[/, "").sub(/\]$/, "")
72
+ return "[#{num}]" if /^\d+$/.match?(num)
71
73
 
72
- num
73
- end
74
+ num
75
+ end
74
76
 
75
- def render_identifier(ident)
76
- [bracket_if_num(ident[0]),
77
- ident[1].nil? ? nil : ident[1].text.sub(/^\[/, "").sub(/\]$/, ""),
78
- ident[2].nil? ? nil : ident[2].text.sub(/^\[/, "").sub(/\]$/, "")]
79
- end
77
+ def render_identifier(ident)
78
+ [bracket_if_num(ident[0]),
79
+ ident[1].nil? ? nil : ident[1].text.sub(/^\[/, "").sub(/\]$/, ""),
80
+ ident[2].nil? ? nil : ident[2].text.sub(/^\[/, "").sub(/\]$/, "")]
81
+ end
80
82
 
81
- def docid_prefix(prefix, docid)
82
- docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
83
- !/^#{prefix}\b/.match(docid)
84
- docid_l10n(docid)
85
- end
83
+ def docid_prefix(prefix, docid)
84
+ docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
85
+ !/^#{prefix}\b/.match(docid)
86
+ docid_l10n(docid)
87
+ end
86
88
 
87
- def omit_docid_prefix(prefix)
88
- return true if prefix.nil? || prefix.empty?
89
+ def omit_docid_prefix(prefix)
90
+ return true if prefix.nil? || prefix.empty?
89
91
 
90
- %w(ISO IEC IEV ITU W3C csd metanorma repository rfc-anchor)
91
- .include? prefix
92
- end
92
+ %w(ISO IEC IEV ITU W3C csd metanorma repository rfc-anchor)
93
+ .include? prefix
94
+ end
93
95
 
94
- def date_note_process(bib, ref)
95
- date_note = bib.at(ns("./note[@type = 'Unpublished-Status']"))
96
- return if date_note.nil?
96
+ def date_note_process(bib, ref)
97
+ date_note = bib.at(ns("./note[@type = 'Unpublished-Status']"))
98
+ return if date_note.nil?
97
99
 
98
- date_note.children.first.replace("<p>#{date_note.content}</p>")
99
- footnote_parse(date_note, ref)
100
- end
100
+ date_note.children.first.replace("<p>#{date_note.content}</p>")
101
+ footnote_parse(date_note, ref)
102
+ end
101
103
 
102
- def iso_bibitem_entry_attrs(bib, biblio)
103
- { id: bib["id"], class: biblio ? "Biblio" : "NormRef" }
104
- end
104
+ def iso_bibitem_entry_attrs(bib, biblio)
105
+ { id: bib["id"], class: biblio ? "Biblio" : "NormRef" }
106
+ end
105
107
 
106
- def iso_title(bib)
107
- bib.at(ns("./title[@language = '#{@lang}' and @type = 'main']")) ||
108
- bib.at(ns("./title[@language = '#{@lang}']")) ||
109
- bib.at(ns("./title[@type = 'main']")) ||
110
- bib.at(ns("./title"))
111
- end
108
+ def iso_title(bib)
109
+ bib.at(ns("./title[@language = '#{@lang}' and @type = 'main']")) ||
110
+ bib.at(ns("./title[@language = '#{@lang}']")) ||
111
+ bib.at(ns("./title[@type = 'main']")) ||
112
+ bib.at(ns("./title"))
113
+ end
112
114
 
113
- # reference not to be rendered because it is deemed implicit
114
- # in the standards environment
115
- def implicit_reference(bib)
116
- bib["hidden"] == "true"
117
- end
115
+ # reference not to be rendered because it is deemed implicit
116
+ # in the standards environment
117
+ def implicit_reference(bib)
118
+ bib["hidden"] == "true"
119
+ end
118
120
 
119
- def prefix_bracketed_ref(ref, text)
120
- ref << text.to_s
121
- insert_tab(ref, 1)
122
- end
121
+ def prefix_bracketed_ref(ref, text)
122
+ ref << text.to_s
123
+ insert_tab(ref, 1)
124
+ end
123
125
 
124
- def reference_format(bib, out)
125
- if ftitle = bib.at(ns("./formattedref"))
126
- ftitle&.children&.each { |n| parse(n, out) }
127
- else
128
- out.i do |i|
129
- iso_title(bib)&.children&.each { |n| parse(n, i) }
126
+ def reference_format(bib, out)
127
+ if ftitle = bib.at(ns("./formattedref"))
128
+ ftitle&.children&.each { |n| parse(n, out) }
129
+ else
130
+ out.i do |i|
131
+ iso_title(bib)&.children&.each { |n| parse(n, i) }
132
+ end
130
133
  end
131
134
  end
132
- end
133
135
 
134
- def is_standard(bib)
135
- ret = false
136
- drop = %w(metanorma DOI ISSN ISBN)
137
- bib.xpath(ns("./docidentifier")).each do |id|
138
- next if id["type"].nil? || drop.include?(id["type"])
136
+ def is_standard(bib)
137
+ ret = false
138
+ drop = %w(metanorma DOI ISSN ISBN)
139
+ bib.xpath(ns("./docidentifier")).each do |id|
140
+ next if id["type"].nil? || drop.include?(id["type"])
139
141
 
140
- ret = true
142
+ ret = true
143
+ end
144
+ ret
141
145
  end
142
- ret
143
- end
144
146
 
145
- def biblio_list(refs, div, biblio)
146
- i = 0
147
- refs.children.each do |b|
148
- if b.name == "bibitem"
149
- next if implicit_reference(b)
150
-
151
- i += 1
152
- if is_standard(b) then std_bibitem_entry(div, b, i, biblio)
153
- else nonstd_bibitem(div, b, i, biblio)
147
+ def biblio_list(refs, div, biblio)
148
+ i = 0
149
+ refs.children.each do |b|
150
+ if b.name == "bibitem"
151
+ next if implicit_reference(b)
152
+
153
+ i += 1
154
+ if is_standard(b) then std_bibitem_entry(div, b, i, biblio)
155
+ else nonstd_bibitem(div, b, i, biblio)
156
+ end
157
+ else
158
+ parse(b, div) unless %w(title).include? b.name
154
159
  end
155
- else
156
- parse(b, div) unless %w(title).include? b.name
157
160
  end
158
161
  end
159
- end
160
162
 
161
- def norm_ref_xpath
162
- "//bibliography/references[@normative = 'true'] | "\
163
- "//bibliography/clause[.//references[@normative = 'true']]"
164
- end
163
+ def norm_ref_xpath
164
+ "//bibliography/references[@normative = 'true'] | "\
165
+ "//bibliography/clause[.//references[@normative = 'true']]"
166
+ end
165
167
 
166
- def norm_ref(isoxml, out, num)
167
- f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true" or return num
168
- out.div do |div|
169
- num = num + 1
170
- clause_name(num, f.at(ns("./title")), div, nil)
171
- if f.name == "clause"
172
- f.elements.each { |e| parse(e, div) unless e.name == "title" }
173
- else biblio_list(f, div, false)
168
+ def norm_ref(isoxml, out, num)
169
+ f = isoxml.at(ns(norm_ref_xpath)) and f["hidden"] != "true" or
170
+ return num
171
+ out.div do |div|
172
+ num = num + 1
173
+ clause_name(num, f.at(ns("./title")), div, nil)
174
+ if f.name == "clause"
175
+ f.elements.each { |e| parse(e, div) unless e.name == "title" }
176
+ else biblio_list(f, div, false)
177
+ end
174
178
  end
179
+ num
175
180
  end
176
- num
177
- end
178
181
 
179
- def bibliography_xpath
180
- "//bibliography/clause[.//references]"\
181
- "[not(.//references[@normative = 'true'])] | "\
182
- "//bibliography/references[@normative = 'false']"
183
- end
182
+ def bibliography_xpath
183
+ "//bibliography/clause[.//references]"\
184
+ "[not(.//references[@normative = 'true'])] | "\
185
+ "//bibliography/references[@normative = 'false']"
186
+ end
184
187
 
185
- def bibliography(isoxml, out)
186
- f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true" or return
187
- page_break(out)
188
- out.div do |div|
189
- div.h1 **{ class: "Section3" } do |h1|
190
- f&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
188
+ def bibliography(isoxml, out)
189
+ f = isoxml.at(ns(bibliography_xpath)) and f["hidden"] != "true" or
190
+ return
191
+ page_break(out)
192
+ out.div do |div|
193
+ div.h1 **{ class: "Section3" } do |h1|
194
+ f&.at(ns("./title"))&.children&.each { |c2| parse(c2, h1) }
195
+ end
196
+ biblio_list(f, div, true)
191
197
  end
192
- biblio_list(f, div, true)
193
198
  end
194
- end
195
199
 
196
- def bibliography_parse(node, out)
197
- node["hidden"] != true or return
198
- out.div do |div|
199
- clause_parse_title(node, div, node.at(ns("./title")), out,
200
- { class: "Section3" })
201
- biblio_list(node, div, true)
200
+ def bibliography_parse(node, out)
201
+ node["hidden"] != true or return
202
+ out.div do |div|
203
+ clause_parse_title(node, div, node.at(ns("./title")), out,
204
+ { class: "Section3" })
205
+ biblio_list(node, div, true)
206
+ end
202
207
  end
203
208
  end
204
209
  end
@@ -1,251 +1,201 @@
1
- module IsoDoc::Function
2
- module Section
3
- def clausedelim
4
- "."
5
- end
6
-
7
- def clausedelimspace(out)
8
- insert_tab(out, 1)
9
- end
10
-
11
- def inline_header_title(out, _node, title)
12
- out.span **{ class: "zzMoveToFollowing" } do |s|
13
- s.b do |b|
14
- title&.children&.each { |c2| parse(c2, b) }
15
- clausedelimspace(out) if /\S/.match?(title&.text)
16
- end
17
- end
18
- end
19
-
20
- # used for subclauses
21
- def clause_parse_title(node, div, title, out, header_class = {})
22
- return if title.nil?
1
+ require_relative "./section_titles"
23
2
 
24
- if node["inline-header"] == "true"
25
- inline_header_title(out, node, title)
26
- else
27
- depth = if title && title["depth"] then title["depth"]
28
- else node.ancestors("clause, annex, terms, references, definitions, "\
29
- "acknowledgements, introduction, foreword").size + 1
30
- end
31
- div.send "h#{depth}", **attr_code(header_class) do |h|
32
- title&.children&.each { |c2| parse(c2, h) }
33
- end
3
+ module IsoDoc
4
+ module Function
5
+ module Section
6
+ def clause_attrs(node)
7
+ { id: node["id"] }
34
8
  end
35
- end
36
9
 
37
- def clause_attrs(node)
38
- { id: node["id"] }
39
- end
40
-
41
- # used for subclauses
42
- def clause_parse(node, out)
43
- out.div **attr_code(clause_attrs(node)) do |div|
44
- clause_parse_title(node, div, node.at(ns("./title")), out)
45
- node.children.reject { |c1| c1.name == "title" }.each do |c1|
46
- parse(c1, div)
47
- end
48
- end
49
- end
50
-
51
- def clause_name(_num, title, div, header_class)
52
- header_class = {} if header_class.nil?
53
- div.h1 **attr_code(header_class) do |h1|
54
- if title.is_a?(String)
55
- h1 << title
56
- else
57
- title&.children&.each { |c2| parse(c2, h1) }
10
+ # used for subclauses
11
+ def clause_parse(node, out)
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|
15
+ parse(c1, div)
16
+ end
58
17
  end
59
18
  end
60
- div.parent.at(".//h1")
61
- end
62
19
 
63
- def clause(isoxml, out)
64
- isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
65
- out.div **attr_code(clause_attrs(c)) do |s|
66
- clause_name(nil, c&.at(ns("./title")), s, nil)
67
- c.elements.reject { |c1| c1.name == "title" }.each do |c1|
68
- parse(c1, s)
20
+ def clause(isoxml, out)
21
+ isoxml.xpath(ns(middle_clause(isoxml))).each do |c|
22
+ out.div **attr_code(clause_attrs(c)) do |s|
23
+ clause_name(nil, c&.at(ns("./title")), s, nil)
24
+ c.elements.reject { |c1| c1.name == "title" }.each do |c1|
25
+ parse(c1, s)
26
+ end
69
27
  end
70
28
  end
71
29
  end
72
- end
73
-
74
- def annex_name(_annex, name, div)
75
- return if name.nil?
76
30
 
77
- div.h1 **{ class: "Annex" } do |t|
78
- name.children.each { |c2| parse(c2, t) }
31
+ def annex_attrs(node)
32
+ { id: node["id"], class: "Section3" }
79
33
  end
80
- end
81
-
82
- def annex_attrs(node)
83
- { id: node["id"], class: "Section3" }
84
- end
85
34
 
86
- def annex(isoxml, out)
87
- isoxml.xpath(ns("//annex")).each do |c|
88
- page_break(out)
89
- out.div **attr_code(annex_attrs(c)) do |s|
90
- c.elements.each do |c1|
91
- if c1.name == "title" then annex_name(c, c1, s)
92
- else
93
- parse(c1, s)
35
+ def annex(isoxml, out)
36
+ isoxml.xpath(ns("//annex")).each do |c|
37
+ page_break(out)
38
+ out.div **attr_code(annex_attrs(c)) do |s|
39
+ c.elements.each do |c1|
40
+ if c1.name == "title" then annex_name(c, c1, s)
41
+ else
42
+ parse(c1, s)
43
+ end
94
44
  end
95
45
  end
96
46
  end
97
47
  end
98
- end
99
48
 
100
- def scope(isoxml, out, num)
101
- f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
102
- out.div **attr_code(id: f["id"]) do |div|
103
- num = num + 1
104
- clause_name(num, f&.at(ns("./title")), div, nil)
105
- f.elements.each do |e|
106
- parse(e, div) unless e.name == "title"
49
+ def scope(isoxml, out, num)
50
+ f = isoxml.at(ns("//clause[@type = 'scope']")) or return num
51
+ out.div **attr_code(id: f["id"]) do |div|
52
+ num = num + 1
53
+ clause_name(num, f&.at(ns("./title")), div, nil)
54
+ f.elements.each do |e|
55
+ parse(e, div) unless e.name == "title"
56
+ end
107
57
  end
58
+ num
108
59
  end
109
- num
110
- end
111
60
 
112
- TERM_CLAUSE = "//sections/terms | "\
113
- "//sections/clause[descendant::terms]".freeze
61
+ TERM_CLAUSE = "//sections/terms | "\
62
+ "//sections/clause[descendant::terms]".freeze
114
63
 
115
- def terms_defs(isoxml, out, num)
116
- f = isoxml.at(ns(TERM_CLAUSE)) or return num
117
- out.div **attr_code(id: f["id"]) do |div|
118
- num = num + 1
119
- clause_name(num, f&.at(ns("./title")), div, nil)
120
- f.elements.each do |e|
121
- parse(e, div) unless %w{title source}.include? e.name
64
+ def terms_defs(isoxml, out, num)
65
+ f = isoxml.at(ns(TERM_CLAUSE)) or return num
66
+ out.div **attr_code(id: f["id"]) do |div|
67
+ num = num + 1
68
+ clause_name(num, f&.at(ns("./title")), div, nil)
69
+ f.elements.each do |e|
70
+ parse(e, div) unless %w{title source}.include? e.name
71
+ end
122
72
  end
73
+ num
123
74
  end
124
- num
125
- end
126
-
127
- # subclause
128
- def terms_parse(isoxml, out)
129
- clause_parse(isoxml, out)
130
- end
131
75
 
132
- def symbols_abbrevs(isoxml, out, num)
133
- f = isoxml.at(ns("//sections/definitions")) or return num
134
- out.div **attr_code(id: f["id"], class: "Symbols") do |div|
135
- num = num + 1
136
- clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
137
- f.elements.each do |e|
138
- parse(e, div) unless e.name == "title"
139
- end
76
+ # subclause
77
+ def terms_parse(isoxml, out)
78
+ clause_parse(isoxml, out)
140
79
  end
141
- num
142
- end
143
-
144
- # subclause
145
- def symbols_parse(isoxml, out)
146
- isoxml.at(ns("./title")) or
147
- isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
148
- clause_parse(isoxml, out)
149
- end
150
80
 
151
- def introduction(isoxml, out)
152
- f = isoxml.at(ns("//introduction")) || return
153
- page_break(out)
154
- out.div **{ class: "Section3", id: f["id"] } do |div|
155
- clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
156
- f.elements.each do |e|
157
- parse(e, div) unless e.name == "title"
81
+ def symbols_abbrevs(isoxml, out, num)
82
+ f = isoxml.at(ns("//sections/definitions")) or return num
83
+ out.div **attr_code(id: f["id"], class: "Symbols") do |div|
84
+ num = num + 1
85
+ clause_name(num, f&.at(ns("./title")) || @i18n.symbols, div, nil)
86
+ f.elements.each do |e|
87
+ parse(e, div) unless e.name == "title"
88
+ end
158
89
  end
90
+ num
159
91
  end
160
- end
161
92
 
162
- def foreword(isoxml, out)
163
- f = isoxml.at(ns("//foreword")) || return
164
- page_break(out)
165
- out.div **attr_code(id: f["id"]) do |s|
166
- clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
167
- { class: "ForewordTitle" })
168
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
93
+ # subclause
94
+ def symbols_parse(isoxml, out)
95
+ isoxml.at(ns("./title")) or
96
+ isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
97
+ clause_parse(isoxml, out)
169
98
  end
170
- end
171
99
 
172
- def acknowledgements(isoxml, out)
173
- f = isoxml.at(ns("//acknowledgements")) || return
174
- title_attr = { class: "IntroTitle" }
175
- page_break(out)
176
- out.div **{ class: "Section3", id: f["id"] } do |div|
177
- clause_name(nil, f&.at(ns("./title")), div, title_attr)
178
- f.elements.each do |e|
179
- parse(e, div) unless e.name == "title"
100
+ def introduction(isoxml, out)
101
+ f = isoxml.at(ns("//introduction")) || return
102
+ page_break(out)
103
+ out.div **{ class: "Section3", id: f["id"] } do |div|
104
+ clause_name(nil, f.at(ns("./title")), div, { class: "IntroTitle" })
105
+ f.elements.each do |e|
106
+ parse(e, div) unless e.name == "title"
107
+ end
180
108
  end
181
109
  end
182
- end
183
110
 
184
- def abstract(isoxml, out)
185
- f = isoxml.at(ns("//preface/abstract")) || return
186
- page_break(out)
187
- out.div **attr_code(id: f["id"]) do |s|
188
- clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
189
- f.elements.each { |e| parse(e, s) unless e.name == "title" }
111
+ def foreword(isoxml, out)
112
+ f = isoxml.at(ns("//foreword")) || return
113
+ page_break(out)
114
+ out.div **attr_code(id: f["id"]) do |s|
115
+ clause_name(nil, f.at(ns("./title")) || @i18n.foreword, s,
116
+ { class: "ForewordTitle" })
117
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
118
+ end
190
119
  end
191
- end
192
120
 
193
- def preface(isoxml, out)
194
- isoxml.xpath(ns("//preface/clause | //preface/references | "\
195
- "//preface/definitions | //preface/terms")).each do |f|
121
+ def acknowledgements(isoxml, out)
122
+ f = isoxml.at(ns("//acknowledgements")) || return
123
+ title_attr = { class: "IntroTitle" }
196
124
  page_break(out)
197
125
  out.div **{ class: "Section3", id: f["id"] } do |div|
198
- clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
126
+ clause_name(nil, f&.at(ns("./title")), div, title_attr)
199
127
  f.elements.each do |e|
200
128
  parse(e, div) unless e.name == "title"
201
129
  end
202
130
  end
203
131
  end
204
- end
205
132
 
206
- def is_clause?(name)
207
- %w(clause references definitions terms foreword introduction abstract
208
- acknowledgements).include? name
209
- end
133
+ def abstract(isoxml, out)
134
+ f = isoxml.at(ns("//preface/abstract")) || return
135
+ page_break(out)
136
+ out.div **attr_code(id: f["id"]) do |s|
137
+ clause_name(nil, f.at(ns("./title")), s, { class: "AbstractTitle" })
138
+ f.elements.each { |e| parse(e, s) unless e.name == "title" }
139
+ end
140
+ end
210
141
 
211
- def preface_block(isoxml, out)
212
- p = isoxml.at(ns("//preface")) or return
213
- p.elements.each do |e|
214
- next if is_clause?(e.name)
142
+ def preface(isoxml, out)
143
+ isoxml.xpath(ns("//preface/clause | //preface/references | "\
144
+ "//preface/definitions | //preface/terms")).each do |f|
145
+ page_break(out)
146
+ out.div **{ class: "Section3", id: f["id"] } do |div|
147
+ clause_name(nil, f&.at(ns("./title")), div, { class: "IntroTitle" })
148
+ f.elements.each do |e|
149
+ parse(e, div) unless e.name == "title"
150
+ end
151
+ end
152
+ end
153
+ end
215
154
 
216
- parse(e, out)
155
+ def is_clause?(name)
156
+ %w(clause references definitions terms foreword introduction abstract
157
+ acknowledgements).include? name
217
158
  end
218
- end
219
159
 
220
- def copyright_parse(node, out)
221
- return if @bare
160
+ def preface_block(isoxml, out)
161
+ p = isoxml.at(ns("//preface")) or return
162
+ p.elements.each do |e|
163
+ next if is_clause?(e.name)
222
164
 
223
- out.div **{ class: "boilerplate-copyright" } do |div|
224
- node.children.each { |n| parse(n, div) }
165
+ parse(e, out)
166
+ end
225
167
  end
226
- end
227
168
 
228
- def license_parse(node, out)
229
- return if @bare
169
+ def copyright_parse(node, out)
170
+ return if @bare
230
171
 
231
- out.div **{ class: "boilerplate-license" } do |div|
232
- node.children.each { |n| parse(n, div) }
172
+ out.div **{ class: "boilerplate-copyright" } do |div|
173
+ node.children.each { |n| parse(n, div) }
174
+ end
233
175
  end
234
- end
235
176
 
236
- def legal_parse(node, out)
237
- return if @bare
177
+ def license_parse(node, out)
178
+ return if @bare
238
179
 
239
- out.div **{ class: "boilerplate-legal" } do |div|
240
- node.children.each { |n| parse(n, div) }
180
+ out.div **{ class: "boilerplate-license" } do |div|
181
+ node.children.each { |n| parse(n, div) }
182
+ end
241
183
  end
242
- end
243
184
 
244
- def feedback_parse(node, out)
245
- return if @bare
185
+ def legal_parse(node, out)
186
+ return if @bare
246
187
 
247
- out.div **{ class: "boilerplate-feedback" } do |div|
248
- node.children.each { |n| parse(n, div) }
188
+ out.div **{ class: "boilerplate-legal" } do |div|
189
+ node.children.each { |n| parse(n, div) }
190
+ end
191
+ end
192
+
193
+ def feedback_parse(node, out)
194
+ return if @bare
195
+
196
+ out.div **{ class: "boilerplate-feedback" } do |div|
197
+ node.children.each { |n| parse(n, div) }
198
+ end
249
199
  end
250
200
  end
251
201
  end