isodoc 1.7.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -1
  3. data/lib/isodoc/convert.rb +1 -0
  4. data/lib/isodoc/css.rb +3 -3
  5. data/lib/isodoc/function/blocks.rb +180 -168
  6. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  7. data/lib/isodoc/function/cleanup.rb +181 -175
  8. data/lib/isodoc/function/inline.rb +110 -108
  9. data/lib/isodoc/function/inline_simple.rb +55 -55
  10. data/lib/isodoc/function/lists.rb +75 -71
  11. data/lib/isodoc/function/references.rb +165 -160
  12. data/lib/isodoc/function/reqt.rb +91 -85
  13. data/lib/isodoc/function/section.rb +140 -190
  14. data/lib/isodoc/function/section_titles.rb +82 -0
  15. data/lib/isodoc/function/table.rb +90 -87
  16. data/lib/isodoc/function/terms.rb +58 -56
  17. data/lib/isodoc/function/to_word_html.rb +208 -204
  18. data/lib/isodoc/html_convert.rb +0 -4
  19. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  20. data/lib/isodoc/presentation_function/inline.rb +1 -1
  21. data/lib/isodoc/presentation_function/math.rb +9 -0
  22. data/lib/isodoc/presentation_function/section.rb +12 -1
  23. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  24. data/lib/isodoc/version.rb +1 -1
  25. data/lib/isodoc/word_function/body.rb +5 -5
  26. data/lib/isodoc/xslfo_convert.rb +2 -2
  27. data/lib/isodoc.rb +2 -1
  28. data/lib/metanorma/output/base.rb +13 -0
  29. data/lib/metanorma/output/utils.rb +17 -0
  30. data/lib/metanorma/output/xslfo.rb +21 -0
  31. data/lib/metanorma/output.rb +7 -0
  32. data/spec/assets/outputtest/a.xml +66 -0
  33. data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
  34. data/spec/isodoc/blocks_spec.rb +441 -243
  35. data/spec/isodoc/inline_spec.rb +197 -114
  36. data/spec/isodoc/postproc_spec.rb +2 -2
  37. data/spec/isodoc/presentation_xml_spec.rb +84 -0
  38. data/spec/isodoc/section_spec.rb +639 -0
  39. metadata +23 -18
  40. data/lib/isodoc/html_function/sectionsplit.rb +0 -244
  41. data/spec/isodoc/sectionsplit_spec.rb +0 -190
@@ -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,115 +1,121 @@
1
- module IsoDoc::Function
2
- module Blocks
3
- def recommendation_labels(node)
4
- [node.at(ns("./label")), node.at(ns("./title")), node.at(ns("./name"))]
5
- end
1
+ module IsoDoc
2
+ module Function
3
+ module Blocks
4
+ def recommendation_labels(node)
5
+ [node.at(ns("./label")), node.at(ns("./title")), node.at(ns("./name"))]
6
+ end
6
7
 
7
- def recommendation_name(node, out, _type)
8
- label, title, lbl = recommendation_labels(node)
9
- out.p **{ class: "RecommendationTitle" } do |b|
10
- lbl and lbl.children.each { |n| parse(n, b) }
11
- b << l10n(":")
12
- if label || title
13
- b.br
14
- label and label.children.each { |n| parse(n,b) }
15
- b << "#{clausedelim} " if label && title
16
- title and title.children.each { |n| parse(n,b) }
8
+ def recommendation_name(node, out, _type)
9
+ label, title, lbl = recommendation_labels(node)
10
+ out.p **{ class: "RecommendationTitle" } do |b|
11
+ lbl&.children&.each { |n| parse(n, b) }
12
+ b << l10n(":")
13
+ if label || title
14
+ b.br
15
+ label&.children&.each { |n| parse(n, b) }
16
+ b << "#{clausedelim} " if label && title
17
+ title&.children&.each { |n| parse(n, b) }
18
+ end
17
19
  end
18
20
  end
19
- end
20
21
 
21
- def recommendation_attributes1(node)
22
- out = []
23
- oblig = node["obligation"] and
24
- out << l10n("#{@i18n.obligation}: #{oblig}")
25
- subj = node&.at(ns("./subject"))&.text and
26
- out << l10n("#{@i18n.subject}: #{subj}")
27
- node.xpath(ns("./inherit")).each do |i|
28
- out << recommendation_attr_parse(i, @i18n.inherits)
22
+ def recommendation_attributes1(node)
23
+ out = []
24
+ oblig = node["obligation"] and
25
+ out << l10n("#{@i18n.obligation}: #{oblig}")
26
+ node.xpath(ns("./subject")).each do |subj|
27
+ out << l10n("#{@i18n.subject}: #{subj.text}")
28
+ end
29
+ node.xpath(ns("./inherit")).each do |i|
30
+ out << recommendation_attr_parse(i, @i18n.inherits)
31
+ end
32
+ node.xpath(ns("./classification")).each do |c|
33
+ line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
34
+ end
35
+ out
29
36
  end
30
- node.xpath(ns("./classification")).each do |c|
31
- line = recommendation_attr_keyvalue(c, "tag", "value") and out << line
37
+
38
+ def recommendation_attr_parse(node, label)
39
+ noko do |xml|
40
+ xml << "#{label}: "
41
+ node.children.each { |n| parse(n, xml) }
42
+ end.join
32
43
  end
33
- out
34
- end
35
44
 
36
- def recommendation_attr_parse(node, label)
37
- noko do |xml|
38
- xml << "#{label}: "
39
- node.children.each { |n| parse(n, xml) }
40
- end.join
41
- end
45
+ def recommendation_attr_keyvalue(node, key, value)
46
+ tag = node.at(ns("./#{key}")) or return nil
47
+ value = node.at(ns("./#{value}")) or return nil
48
+ "#{tag.text.capitalize}: #{value.text}"
49
+ end
42
50
 
43
- def recommendation_attr_keyvalue(node, key, value)
44
- tag = node.at(ns("./#{key}")) or return nil
45
- value = node.at(ns("./#{value}")) or return nil
46
- "#{tag.text.capitalize}: #{value.text}"
47
- end
51
+ def recommendation_attributes(node, out)
52
+ ret = recommendation_attributes1(node)
53
+ return if ret.empty?
48
54
 
49
- def recommendation_attributes(node, out)
50
- ret = recommendation_attributes1(node)
51
- return if ret.empty?
52
- out.p do |p|
53
- p.i do |i|
54
- i << ret.join("<br/>")
55
+ out.p do |p|
56
+ p.i do |i|
57
+ i << ret.join("<br/>")
58
+ end
55
59
  end
56
60
  end
57
- end
58
61
 
59
- def reqt_metadata_node(n)
60
- %w(label title subject classification tag value
61
- inherit name).include? n.name
62
- end
62
+ def reqt_metadata_node(node)
63
+ %w(label title subject classification tag value
64
+ inherit name).include? node.name
65
+ end
63
66
 
64
- def reqt_attrs(node, klass)
65
- attr_code(class: klass, id: node["id"], style: keep_style(node))
66
- end
67
+ def reqt_attrs(node, klass)
68
+ attr_code(class: klass, id: node["id"], style: keep_style(node))
69
+ end
67
70
 
68
- def recommendation_parse(node, out)
69
- out.div **reqt_attrs(node, "recommend") do |t|
70
- recommendation_name(node, t, @i18n.recommendation)
71
- recommendation_attributes(node, out)
72
- node.children.each do |n|
73
- parse(n, t) unless reqt_metadata_node(n)
71
+ def recommendation_parse(node, out)
72
+ out.div **reqt_attrs(node, "recommend") do |t|
73
+ recommendation_name(node, t, @i18n.recommendation)
74
+ recommendation_attributes(node, out)
75
+ node.children.each do |n|
76
+ parse(n, t) unless reqt_metadata_node(n)
77
+ end
74
78
  end
75
79
  end
76
- end
77
80
 
78
- def requirement_parse(node, out)
79
- out.div **reqt_attrs(node, "require") do |t|
80
- recommendation_name(node, t, @i18n.requirement)
81
- recommendation_attributes(node, out)
82
- node.children.each do |n|
83
- parse(n, t) unless reqt_metadata_node(n)
81
+ def requirement_parse(node, out)
82
+ out.div **reqt_attrs(node, "require") do |t|
83
+ recommendation_name(node, t, @i18n.requirement)
84
+ recommendation_attributes(node, out)
85
+ node.children.each do |n|
86
+ parse(n, t) unless reqt_metadata_node(n)
87
+ end
84
88
  end
85
89
  end
86
- end
87
90
 
88
- def permission_parse(node, out)
89
- out.div **reqt_attrs(node, "permission") do |t|
90
- recommendation_name(node, t, @i18n.permission)
91
- recommendation_attributes(node, out)
92
- node.children.each do |n|
93
- parse(n, t) unless reqt_metadata_node(n)
91
+ def permission_parse(node, out)
92
+ out.div **reqt_attrs(node, "permission") do |t|
93
+ recommendation_name(node, t, @i18n.permission)
94
+ recommendation_attributes(node, out)
95
+ node.children.each do |n|
96
+ parse(n, t) unless reqt_metadata_node(n)
97
+ end
94
98
  end
95
99
  end
96
- end
97
100
 
98
- def reqt_component_attrs(node)
99
- attr_code(class: "requirement-" + node.name,
100
- style: keep_style(node))
101
- end
101
+ def reqt_component_attrs(node)
102
+ klass = node.name
103
+ klass == "component" and klass = node["class"]
104
+ attr_code(class: "requirement-#{klass}",
105
+ style: keep_style(node))
106
+ end
102
107
 
103
- def requirement_component_parse(node, out)
104
- return if node["exclude"] == "true"
105
- out.div **reqt_component_attrs(node) do |div|
106
- node.children.each do |n|
107
- parse(n, div)
108
+ def requirement_component_parse(node, out)
109
+ return if node["exclude"] == "true"
110
+
111
+ out.div **reqt_component_attrs(node) do |div|
112
+ node.children.each do |n|
113
+ parse(n, div)
114
+ end
108
115
  end
109
116
  end
110
- end
111
117
 
112
- def requirement_skip_parse(node, out)
118
+ def requirement_skip_parse(node, out); end
113
119
  end
114
120
  end
115
121
  end