isodoc 1.0.28 → 1.1.3.pre.alpha

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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +4 -8
  3. data/.github/workflows/ubuntu.yml +18 -16
  4. data/.github/workflows/windows.yml +4 -8
  5. data/Rakefile +3 -1
  6. data/isodoc.gemspec +2 -2
  7. data/lib/isodoc.rb +2 -0
  8. data/lib/isodoc/base_style/metanorma_word.scss +0 -1
  9. data/lib/isodoc/base_style/reset.scss +3 -3
  10. data/lib/isodoc/common.rb +0 -4
  11. data/lib/isodoc/convert.rb +121 -58
  12. data/lib/isodoc/function/blocks.rb +42 -53
  13. data/lib/isodoc/function/blocks_example_note.rb +108 -0
  14. data/lib/isodoc/function/i18n.rb +1 -0
  15. data/lib/isodoc/function/inline.rb +25 -8
  16. data/lib/isodoc/function/lists.rb +12 -6
  17. data/lib/isodoc/function/references.rb +31 -36
  18. data/lib/isodoc/function/reqt.rb +14 -5
  19. data/lib/isodoc/function/section.rb +7 -11
  20. data/lib/isodoc/function/table.rb +4 -4
  21. data/lib/isodoc/function/terms.rb +3 -3
  22. data/lib/isodoc/function/to_word_html.rb +2 -2
  23. data/lib/isodoc/function/utils.rb +57 -50
  24. data/lib/isodoc/gem_tasks.rb +110 -0
  25. data/lib/isodoc/headlesshtml_convert.rb +7 -6
  26. data/lib/isodoc/html_convert.rb +2 -1
  27. data/lib/isodoc/html_function/html.rb +2 -2
  28. data/lib/isodoc/html_function/postprocess.rb +1 -1
  29. data/lib/isodoc/metadata.rb +69 -63
  30. data/lib/isodoc/pdf_convert.rb +8 -6
  31. data/lib/isodoc/presentation_xml_convert.rb +29 -0
  32. data/lib/isodoc/sassc_importer.rb +11 -0
  33. data/lib/isodoc/version.rb +1 -1
  34. data/lib/isodoc/word_convert.rb +2 -1
  35. data/lib/isodoc/word_function/body.rb +14 -48
  36. data/lib/isodoc/word_function/inline.rb +75 -0
  37. data/lib/isodoc/word_function/postprocess.rb +1 -0
  38. data/lib/isodoc/word_function/table.rb +3 -3
  39. data/lib/isodoc/xref.rb +59 -0
  40. data/lib/isodoc/{function → xref}/xref_anchor.rb +10 -21
  41. data/lib/isodoc/xref/xref_counter.rb +74 -0
  42. data/lib/isodoc/{function → xref}/xref_gen.rb +9 -22
  43. data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
  44. data/lib/isodoc/{function → xref}/xref_sect_gen.rb +33 -23
  45. data/lib/isodoc/xslfo_convert.rb +16 -4
  46. data/spec/assets/{html.css → html.scss} +0 -0
  47. data/spec/assets/odf.emf +0 -0
  48. data/spec/assets/odf.svg +4 -0
  49. data/spec/assets/odf1.svg +4 -0
  50. data/spec/isodoc/blocks_spec.rb +216 -44
  51. data/spec/isodoc/footnotes_spec.rb +2 -2
  52. data/spec/isodoc/inline_spec.rb +208 -1
  53. data/spec/isodoc/lists_spec.rb +8 -8
  54. data/spec/isodoc/metadata_spec.rb +107 -3
  55. data/spec/isodoc/postproc_spec.rb +1320 -1350
  56. data/spec/isodoc/presentation_xml_spec.rb +20 -0
  57. data/spec/isodoc/ref_spec.rb +5 -5
  58. data/spec/isodoc/section_spec.rb +52 -0
  59. data/spec/isodoc/table_spec.rb +4 -4
  60. data/spec/isodoc/terms_spec.rb +7 -7
  61. data/spec/isodoc/xref_spec.rb +165 -45
  62. metadata +37 -29
  63. data/lib/isodoc/function/blocks_example.rb +0 -53
  64. data/lib/isodoc/function/xref_counter.rb +0 -50
@@ -1,48 +1,12 @@
1
- require_relative "blocks_example"
1
+ require_relative "blocks_example_note"
2
2
 
3
3
  module IsoDoc::Function
4
4
  module Blocks
5
5
  @annotation = false
6
6
 
7
- def note_label(node)
8
- n = get_anchors[node["id"]]
9
- return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
10
- l10n("#{@note_lbl} #{n[:label]}")
11
- end
12
-
13
- def note_p_parse(node, div)
14
- div.p do |p|
15
- p.span **{ class: "note_label" } do |s|
16
- s << note_label(node)
17
- end
18
- insert_tab(p, 1)
19
- node.first_element_child.children.each { |n| parse(n, p) }
20
- end
21
- node.element_children[1..-1].each { |n| parse(n, div) }
22
- end
23
-
24
- def note_parse1(node, div)
25
- div.p do |p|
26
- p.span **{ class: "note_label" } do |s|
27
- s << note_label(node)
28
- end
29
- insert_tab(p, 1)
30
- end
31
- node.children.each { |n| parse(n, div) }
32
- end
33
-
34
- def note_parse(node, out)
35
- @note = true
36
- out.div **{ id: node["id"], class: "Note" } do |div|
37
- node.first_element_child.name == "p" ?
38
- note_p_parse(node, div) : note_parse1(node, div)
39
- end
40
- @note = false
41
- end
42
-
43
7
  def figure_name_parse(node, div, name)
44
8
  return if name.nil? && node.at(ns("./figure"))
45
- lbl = anchor(node['id'], :label, false)
9
+ lbl = @xrefs.anchor(node['id'], :label, false)
46
10
  lbl = nil if labelled_ancestor(node) && node.ancestors("figure").empty?
47
11
  return if lbl.nil? && name.nil?
48
12
  div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
@@ -58,11 +22,15 @@ module IsoDoc::Function
58
22
  end
59
23
  end
60
24
 
25
+ def figure_attrs(node)
26
+ attr_code(id: node["id"], class: "figure", style: keep_style(node))
27
+ end
28
+
61
29
  def figure_parse(node, out)
62
30
  return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
63
31
  node["type"] == "pseudocode"
64
32
  @in_figure = true
65
- out.div **attr_code(id: node["id"], class: "figure") do |div|
33
+ out.div **figure_attrs(node) do |div|
66
34
  node.children.each do |n|
67
35
  figure_key(out) if n.name == "dl"
68
36
  parse(n, div) unless n.name == "name"
@@ -72,10 +40,14 @@ module IsoDoc::Function
72
40
  @in_figure = false
73
41
  end
74
42
 
43
+ def pseudocode_attrs(node)
44
+ attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
45
+ end
46
+
75
47
  def pseudocode_parse(node, out)
76
48
  @in_figure = true
77
49
  name = node.at(ns("./name"))
78
- out.div **attr_code(id: node["id"], class: "pseudocode") do |div|
50
+ out.div **pseudocode_attrs(node) do |div|
79
51
  node.children.each { |n| parse(n, div) unless n.name == "name" }
80
52
  sourcecode_name_parse(node, div, name)
81
53
  end
@@ -83,7 +55,7 @@ module IsoDoc::Function
83
55
  end
84
56
 
85
57
  def sourcecode_name_parse(node, div, name)
86
- lbl = anchor(node['id'], :label, false)
58
+ lbl = @xrefs.anchor(node['id'], :label, false)
87
59
  lbl = nil if labelled_ancestor(node)
88
60
  return if lbl.nil? && name.nil?
89
61
  div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
@@ -101,9 +73,13 @@ module IsoDoc::Function
101
73
  end
102
74
  end
103
75
 
76
+ def sourcecode_attrs(node)
77
+ attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
78
+ end
79
+
104
80
  def sourcecode_parse(node, out)
105
81
  name = node.at(ns("./name"))
106
- out.p **attr_code(id: node["id"], class: "Sourcecode") do |div|
82
+ out.p **sourcecode_attrs(node) do |div|
107
83
  @sourcecode = true
108
84
  node.children.each { |n| parse(n, div) unless n.name == "name" }
109
85
  @sourcecode = false
@@ -138,10 +114,15 @@ module IsoDoc::Function
138
114
  name
139
115
  end
140
116
 
117
+ def admonition_attrs(node)
118
+ attr_code(id: node["id"], class: admonition_class(node),
119
+ style: keep_style(node))
120
+ end
121
+
141
122
  def admonition_parse(node, out)
142
123
  type = node["type"]
143
124
  name = admonition_name(node, type)
144
- out.div **{ id: node["id"], class: admonition_class(node) } do |t|
125
+ out.div **admonition_attrs(node) do |t|
145
126
  admonition_name_parse(node, t, name) if name
146
127
  node.children.each { |n| parse(n, t) unless n.name == "name" }
147
128
  end
@@ -157,10 +138,10 @@ module IsoDoc::Function
157
138
  end
158
139
 
159
140
  def formula_parse1(node, out)
160
- out.div **attr_code(id: node["id"], class: "formula") do |div|
141
+ out.div **attr_code(class: "formula") do |div|
161
142
  div.p do |p|
162
143
  parse(node.at(ns("./stem")), div)
163
- lbl = anchor(node['id'], :label, false)
144
+ lbl = @xrefs.anchor(node['id'], :label, false)
164
145
  unless lbl.nil?
165
146
  insert_tab(div, 1)
166
147
  div << "(#{lbl})"
@@ -169,12 +150,18 @@ module IsoDoc::Function
169
150
  end
170
151
  end
171
152
 
153
+ def formula_attrs(node)
154
+ attr_code(id: node["id"], style: keep_style(node))
155
+ end
156
+
172
157
  def formula_parse(node, out)
173
- formula_parse1(node, out)
174
- formula_where(node.at(ns("./dl")), out)
175
- node.children.each do |n|
176
- next if %w(stem dl).include? n.name
177
- parse(n, out)
158
+ out.div **formula_attrs(node) do |div|
159
+ formula_parse1(node, div)
160
+ formula_where(node.at(ns("./dl")), div)
161
+ node.children.each do |n|
162
+ next if %w(stem dl).include? n.name
163
+ parse(n, div)
164
+ end
178
165
  end
179
166
  end
180
167
 
@@ -187,8 +174,9 @@ module IsoDoc::Function
187
174
 
188
175
  def para_attrs(node)
189
176
  attrs = { class: para_class(node), id: node["id"] }
190
- node["align"].nil? or
191
- attrs[:style] = "text-align:#{node['align']};"
177
+ s = node["align"].nil? ? "" : "text-align:#{node['align']};"
178
+ s = "#{s}#{keep_style(node)}"
179
+ attrs[:style] = s unless s.empty?
192
180
  attrs
193
181
  end
194
182
 
@@ -224,7 +212,8 @@ module IsoDoc::Function
224
212
  end
225
213
 
226
214
  def passthrough_parse(node, out)
227
- return if node["format"] and !(node["format"].split(/,/).include? @format.to_s)
215
+ return if node["format"] and
216
+ !(node["format"].split(/,/).include? @format.to_s)
228
217
  out.passthrough node.text
229
218
  end
230
219
  end
@@ -0,0 +1,108 @@
1
+ module IsoDoc::Function
2
+ module Blocks
3
+ def example_label(node, div, name)
4
+ n = @xrefs.get[node["id"]]
5
+ div.p **{ class: "example-title" } do |p|
6
+ lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @example_lbl :
7
+ l10n("#{@example_lbl} #{n[:label]}")
8
+ p << lbl
9
+ name and !lbl.nil? and p << "&nbsp;&mdash; "
10
+ name and name.children.each { |n| parse(n, div) }
11
+ end
12
+ end
13
+
14
+ EXAMPLE_TBL_ATTR =
15
+ { class: "example_label", style: "width:82.8pt;padding:0 0 0 0;\
16
+ margin-left:0pt;vertical-align:top;" }.freeze
17
+
18
+ def example_div_attr(node)
19
+ attr_code(id: node["id"], class: "example", style: keep_style(node))
20
+ end
21
+
22
+ # used if we are boxing examples
23
+ def example_div_parse(node, out)
24
+ out.div **example_div_attr(node) do |div|
25
+ example_label(node, div, node.at(ns("./name")))
26
+ node.children.each do |n|
27
+ parse(n, div) unless n.name == "name"
28
+ end
29
+ end
30
+ end
31
+
32
+ def example_table_attr(node)
33
+ attr_code(id: node["id"], class: "example",
34
+ style: "border-collapse:collapse;border-spacing:0;"\
35
+ "#{keep_style(node)}" )
36
+ end
37
+
38
+ EXAMPLE_TD_ATTR =
39
+ { style: "vertical-align:top;padding:0;", class: "example" }.freeze
40
+
41
+ def example_table_parse(node, out)
42
+ out.table **example_table_attr(node) do |t|
43
+ t.tr do |tr|
44
+ tr.td **EXAMPLE_TBL_ATTR do |td|
45
+ example_label(node, td, node.at(ns("./name")))
46
+ end
47
+ tr.td **EXAMPLE_TD_ATTR do |td|
48
+ node.children.each { |n| parse(n, td) unless n.name == "name" }
49
+ end
50
+ end
51
+ end
52
+ end
53
+
54
+ def example_parse(node, out)
55
+ example_div_parse(node, out)
56
+ end
57
+
58
+ def note_label(node)
59
+ n = @xrefs.get[node["id"]]
60
+ return @note_lbl if n.nil? || n[:label].nil? || n[:label].empty?
61
+ l10n("#{@note_lbl} #{n[:label]}")
62
+ end
63
+
64
+ def note_p_parse(node, div)
65
+ div.p do |p|
66
+ p.span **{ class: "note_label" } do |s|
67
+ s << note_label(node)
68
+ end
69
+ insert_tab(p, 1)
70
+ node.first_element_child.children.each { |n| parse(n, p) }
71
+ end
72
+ node.element_children[1..-1].each { |n| parse(n, div) }
73
+ end
74
+
75
+ def note_parse1(node, div)
76
+ div.p do |p|
77
+ p.span **{ class: "note_label" } do |s|
78
+ s << note_label(node)
79
+ end
80
+ insert_tab(p, 1)
81
+ end
82
+ node.children.each { |n| parse(n, div) }
83
+ end
84
+
85
+ def keep_style(node)
86
+ ret = ""
87
+ node["keep-with-next"] == "true" and
88
+ ret += "page-break-after: avoid;"
89
+ node["keep-lines-together"] == "true" and
90
+ ret += "page-break-inside: avoid;"
91
+ return nil if ret.empty?
92
+ ret
93
+ end
94
+
95
+ def note_attrs(node)
96
+ attr_code(id: node["id"], class: "Note", style: keep_style(node))
97
+ end
98
+
99
+ def note_parse(node, out)
100
+ @note = true
101
+ out.div **note_attrs(node) do |div|
102
+ node.first_element_child.name == "p" ?
103
+ note_p_parse(node, div) : note_parse1(node, div)
104
+ end
105
+ @note = false
106
+ end
107
+ end
108
+ end
@@ -87,6 +87,7 @@ module IsoDoc::Function
87
87
 
88
88
  # TODO: move to localization file
89
89
  def eref_localities1(target, type, from, to, delim, lang = "en")
90
+ return "" if type == "anchor"
90
91
  return l10n(eref_localities1_zh(target, type, from, to, delim)) if lang == "zh"
91
92
  ret = delim
92
93
  loc = @locality[type] || type.sub(/^locality:/, "").capitalize
@@ -17,17 +17,17 @@ module IsoDoc::Function
17
17
  end
18
18
 
19
19
  def prefix_container(container, linkend, _target)
20
- l10n(anchor(container, :xref) + ", " + linkend)
20
+ l10n(@xrefs.anchor(container, :xref) + ", " + linkend)
21
21
  end
22
22
 
23
23
  def anchor_linkend(node, linkend)
24
24
  if node["citeas"].nil? && node["bibitemid"]
25
- return anchor(node["bibitemid"] ,:xref) || "???"
25
+ return @xrefs.anchor(node["bibitemid"] ,:xref) || "???"
26
26
  elsif node["target"] && !/.#./.match(node["target"])
27
- linkend = anchor(node["target"], :xref)
28
- container = anchor(node["target"], :container, false)
27
+ linkend = @xrefs.anchor(node["target"], :xref)
28
+ container = @xrefs.anchor(node["target"], :container, false)
29
29
  (container && get_note_container_id(node) != container &&
30
- @anchors[node["target"]]) &&
30
+ @xrefs.get[node["target"]]) &&
31
31
  linkend = prefix_container(container, linkend, node["target"])
32
32
  linkend = capitalise_xref(node, linkend)
33
33
  end
@@ -90,21 +90,38 @@ module IsoDoc::Function
90
90
  end
91
91
 
92
92
  def eref_localities0(r, i, target, delim)
93
- if r["type"] == "whole" then l10n("#{delim} #{@whole_of_text}")
93
+ if r["type"] == "whole" then l10n("#{delim} #{@wholeoftext_lbl}")
94
94
  else
95
95
  eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
96
96
  r.at(ns("./referenceTo")), delim, @lang)
97
97
  end
98
98
  end
99
99
 
100
+ def suffix_url(url)
101
+ return url if %r{^http[s]?://}.match(url)
102
+ url.sub(/#{File.extname(url)}$/, ".html")
103
+ end
104
+
105
+ def eref_target(node)
106
+ href = "#" + node["bibitemid"]
107
+ url = node.at(ns("//bibitem[@id = '#{node['bibitemid']}']/"\
108
+ "uri[@type = 'citation']"))
109
+ return href unless url
110
+ href = suffix_url(url.text)
111
+ anchor = node&.at(ns(".//locality[@type = 'anchor']"))&.text
112
+ anchor and href += "##{anchor}"
113
+ href
114
+ end
115
+
100
116
  def eref_parse(node, out)
101
117
  linkend = get_linkend(node)
118
+ href = eref_target(node)
102
119
  if node["type"] == "footnote"
103
120
  out.sup do |s|
104
- s.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
121
+ s.a(**{ "href": href }) { |l| l << linkend }
105
122
  end
106
123
  else
107
- out.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
124
+ out.a(**{ "href": href }) { |l| l << linkend }
108
125
  end
109
126
  end
110
127
 
@@ -1,8 +1,11 @@
1
1
  module IsoDoc::Function
2
2
  module Lists
3
+ def ul_attrs(node)
4
+ { id: node["id"], style: keep_style(node) }
5
+ end
3
6
 
4
7
  def ul_parse(node, out)
5
- out.ul **attr_code(id: node["id"]) do |ul|
8
+ out.ul **attr_code(ul_attrs(node)) do |ul|
6
9
  node.children.each { |n| parse(n, ul) }
7
10
  end
8
11
  end
@@ -34,9 +37,12 @@ module IsoDoc::Function
34
37
  ol_style(type)
35
38
  end
36
39
 
40
+ def ol_attrs(node)
41
+ { type: ol_depth(node), id: node["id"], style: keep_style(node) }
42
+ end
43
+
37
44
  def ol_parse(node, out)
38
- style = ol_depth(node)
39
- out.ol **attr_code(type: style, id: node["id"] ) do |ol|
45
+ out.ol **attr_code(ol_attrs(node)) do |ol|
40
46
  node.children.each { |n| parse(n, ol) }
41
47
  end
42
48
  end
@@ -67,12 +73,12 @@ module IsoDoc::Function
67
73
  %w{dt dd}.include? n.name
68
74
  end
69
75
 
70
- def dl_attr(node)
71
- attr_code(id: node["id"])
76
+ def dl_attrs(node)
77
+ attr_code(id: node["id"], style: keep_style(node))
72
78
  end
73
79
 
74
80
  def dl_parse(node, out)
75
- out.dl **dl_attr(node) do |v|
81
+ out.dl **dl_attrs(node) do |v|
76
82
  node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
77
83
  v.dt **attr_code(id: dt["id"]) do |term|
78
84
  dt_parse(dt, term)
@@ -6,6 +6,7 @@ module IsoDoc::Function
6
6
  def docid_l10n(x)
7
7
  return x if x.nil?
8
8
  x.gsub(/All Parts/i, @all_parts_lbl.downcase) if @all_parts_lbl
9
+ x
9
10
  end
10
11
 
11
12
  # TODO generate formatted ref if not present
@@ -15,22 +16,24 @@ module IsoDoc::Function
15
16
  identifiers = render_identifier(ids)
16
17
  if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
17
18
  else
18
- ref << "#{identifiers[0] || identifiers[1]}, "
19
- ref << "#{identifiers[1]}, " if identifiers[0] && identifiers[1]
19
+ ref << "#{identifiers[0] || identifiers[1]}"
20
+ ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
20
21
  end
22
+ ref << ", " unless biblio && !identifiers[1]
21
23
  reference_format(b, ref)
22
24
  end
23
25
  end
24
26
 
25
27
  def std_bibitem_entry(list, b, ordinal, biblio)
26
28
  list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
27
- ids = bibitem_ref_code(b)
28
- identifiers = render_identifier(ids)
29
- prefix_bracketed_ref(ref, "[#{ordinal}]") if biblio
30
- ref << "#{identifiers[0] || identifiers[1]}"
31
- ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
29
+ identifiers = render_identifier(bibitem_ref_code(b))
30
+ if biblio then ref_entry_code(ref, ordinal, identifiers, nil)
31
+ else
32
+ ref << "#{identifiers[0] || identifiers[1]}"
33
+ ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
34
+ end
32
35
  date_note_process(b, ref)
33
- ref << ", "
36
+ ref << ", " unless biblio && !identifiers[1]
34
37
  reference_format(b, ref)
35
38
  end
36
39
  end
@@ -39,9 +42,7 @@ module IsoDoc::Function
39
42
  # else, use both ordinal, as prefix, and t
40
43
  def ref_entry_code(r, ordinal, t, id)
41
44
  prefix_bracketed_ref(r, t[0] || "[#{ordinal}]")
42
- if t[1]
43
- r << "#{t[1]}, "
44
- end
45
+ t[1] and r << "#{t[1]}"
45
46
  end
46
47
 
47
48
  def pref_ref_code(b)
@@ -88,9 +89,8 @@ module IsoDoc::Function
88
89
  end
89
90
 
90
91
  def date_note_process(b, ref)
91
- date_note = b.at(ns("./note[text()][contains(.,'ISO DATE:')]"))
92
+ date_note = b.at(ns("./note[@type = 'ISO DATE']"))
92
93
  return if date_note.nil?
93
- date_note.content = date_note.content.gsub(/ISO DATE: /, "")
94
94
  date_note.children.first.replace("<p>#{date_note.content}</p>")
95
95
  footnote_parse(date_note, ref)
96
96
  end
@@ -129,12 +129,6 @@ module IsoDoc::Function
129
129
  end
130
130
  end
131
131
 
132
- ISO_PUBLISHER_XPATH =
133
- "./contributor[xmlns:role/@type = 'publisher']/"\
134
- "organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
135
- "xmlns:name = 'International Organization for Standardization' or "\
136
- "xmlns:name = 'International Electrotechnical Commission']".freeze
137
-
138
132
  def is_standard(b)
139
133
  ret = false
140
134
  b.xpath(ns("./docidentifier")).each do |id|
@@ -159,22 +153,33 @@ module IsoDoc::Function
159
153
  end
160
154
  end
161
155
 
156
+ def norm_ref_xpath
157
+ "//bibliography/references[@normative = 'true'] | "\
158
+ "//bibliography/clause[.//references[@normative = 'true']]"
159
+ end
160
+
162
161
  def norm_ref(isoxml, out, num)
163
- q = "//bibliography/references[@normative = 'true']"
164
- f = isoxml.at(ns(q)) or return num
162
+ f = isoxml.at(ns(norm_ref_xpath)) or return num
165
163
  out.div do |div|
166
164
  num = num + 1
167
165
  clause_name(num, @normref_lbl, div, nil)
168
- biblio_list(f, div, false)
166
+ if f.name == "clause"
167
+ f.elements.each { |e| parse(e, div) unless e.name == "title" }
168
+ else
169
+ biblio_list(f, div, false)
170
+ end
169
171
  end
170
172
  num
171
173
  end
172
174
 
173
- BIBLIOGRAPHY_XPATH = "//bibliography/clause[.//references[@normative = 'false']] | "\
174
- "//bibliography/references[@normative = 'false']".freeze
175
+ def bibliography_xpath
176
+ "//bibliography/clause[.//references]"\
177
+ "[not(.//references[@normative = 'true'])] | "\
178
+ "//bibliography/references[@normative = 'false']"
179
+ end
175
180
 
176
181
  def bibliography(isoxml, out)
177
- f = isoxml.at(ns(BIBLIOGRAPHY_XPATH)) || return
182
+ f = isoxml.at(ns(bibliography_xpath)) || return
178
183
  page_break(out)
179
184
  out.div do |div|
180
185
  div.h1 @bibliography_lbl, **{ class: "Section3" }
@@ -185,7 +190,7 @@ module IsoDoc::Function
185
190
  def bibliography_parse(node, out)
186
191
  title = node&.at(ns("./title"))&.text || ""
187
192
  out.div do |div|
188
- anchor(node['id'], :label, false) and
193
+ @xrefs.anchor(node['id'], :label, false) and
189
194
  clause_parse_title(node, div, node.at(ns("./title")), out) or
190
195
  div.h2 title, **{ class: "Section3" }
191
196
  biblio_list(node, div, true)
@@ -199,16 +204,6 @@ module IsoDoc::Function
199
204
  ref
200
205
  end
201
206
 
202
- def reference_names(ref)
203
- isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
204
- ids = bibitem_ref_code(ref)
205
- identifiers = render_identifier(ids)
206
- date = ref.at(ns("./date[@type = 'published']"))
207
- allparts = ref.at(ns("./extent[@type='part'][referenceFrom='all']"))
208
- reference = docid_l10n(identifiers[0] || identifiers[1])
209
- @anchors[ref["id"]] = { xref: reference }
210
- end
211
-
212
207
  # def ref_names(ref)
213
208
  # linkend = ref.text
214
209
  # linkend.gsub!(/[\[\]]/, "") unless /^\[\d+\]$/.match linkend