isodoc 1.0.25 → 1.1.0

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/macos.yml +12 -2
  3. data/.github/workflows/ubuntu.yml +15 -3
  4. data/.github/workflows/windows.yml +12 -2
  5. data/isodoc.gemspec +2 -2
  6. data/lib/isodoc.rb +2 -0
  7. data/lib/isodoc/common.rb +0 -4
  8. data/lib/isodoc/convert.rb +18 -8
  9. data/lib/isodoc/function/blocks.rb +46 -52
  10. data/lib/isodoc/function/blocks_example_note.rb +108 -0
  11. data/lib/isodoc/function/cleanup.rb +14 -2
  12. data/lib/isodoc/function/i18n.rb +1 -0
  13. data/lib/isodoc/function/inline.rb +76 -82
  14. data/lib/isodoc/function/inline_simple.rb +72 -0
  15. data/lib/isodoc/function/lists.rb +12 -6
  16. data/lib/isodoc/function/references.rb +49 -53
  17. data/lib/isodoc/function/reqt.rb +14 -5
  18. data/lib/isodoc/function/section.rb +10 -12
  19. data/lib/isodoc/function/table.rb +4 -5
  20. data/lib/isodoc/function/terms.rb +3 -3
  21. data/lib/isodoc/function/to_word_html.rb +22 -12
  22. data/lib/isodoc/function/utils.rb +9 -3
  23. data/lib/isodoc/headlesshtml_convert.rb +12 -6
  24. data/lib/isodoc/html_convert.rb +7 -1
  25. data/lib/isodoc/html_function/footnotes.rb +1 -1
  26. data/lib/isodoc/html_function/html.rb +16 -1
  27. data/lib/isodoc/html_function/postprocess.rb +6 -5
  28. data/lib/isodoc/metadata.rb +6 -0
  29. data/lib/isodoc/metadata_date.rb +19 -7
  30. data/lib/isodoc/pdf_convert.rb +13 -6
  31. data/lib/isodoc/presentation_xml_convert.rb +29 -0
  32. data/lib/isodoc/version.rb +1 -1
  33. data/lib/isodoc/word_convert.rb +7 -1
  34. data/lib/isodoc/word_function/body.rb +14 -48
  35. data/lib/isodoc/word_function/footnotes.rb +1 -1
  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 +11 -23
  43. data/lib/isodoc/{function → xref}/xref_gen_seq.rb +41 -32
  44. data/lib/isodoc/{function → xref}/xref_sect_gen.rb +54 -40
  45. data/lib/isodoc/xslfo_convert.rb +21 -4
  46. data/spec/assets/i18n.yaml +4 -1
  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 +271 -48
  51. data/spec/isodoc/cleanup_spec.rb +139 -17
  52. data/spec/isodoc/footnotes_spec.rb +20 -5
  53. data/spec/isodoc/i18n_spec.rb +8 -8
  54. data/spec/isodoc/inline_spec.rb +299 -4
  55. data/spec/isodoc/lists_spec.rb +8 -8
  56. data/spec/isodoc/metadata_spec.rb +110 -3
  57. data/spec/isodoc/postproc_spec.rb +10 -14
  58. data/spec/isodoc/presentation_xml_spec.rb +20 -0
  59. data/spec/isodoc/ref_spec.rb +121 -52
  60. data/spec/isodoc/section_spec.rb +232 -208
  61. data/spec/isodoc/table_spec.rb +28 -28
  62. data/spec/isodoc/terms_spec.rb +7 -7
  63. data/spec/isodoc/xref_spec.rb +206 -59
  64. metadata +24 -17
  65. data/lib/isodoc/function/blocks_example.rb +0 -53
  66. data/lib/isodoc/function/xref_counter.rb +0 -50
@@ -1,13 +1,25 @@
1
1
  module IsoDoc::Function
2
2
  module Cleanup
3
3
  def textcleanup(docxml)
4
+ docxml = termref_cleanup(passthrough_cleanup(docxml))
5
+ end
6
+
7
+ def termref_cleanup(docxml)
4
8
  docxml.
9
+ gsub(%r{\s*\[/TERMREF\]\s*</p>\s*<p>\s*\[TERMREF\]}, "; ").
5
10
  gsub(/\[TERMREF\]\s*/, l10n("[#{@source_lbl}: ")).
6
11
  gsub(/\s*\[MODIFICATION\]\s*\[\/TERMREF\]/, l10n(", #{@modified_lbl} [/TERMREF]")).
7
- gsub(/\s*\[\/TERMREF\]\s*/, l10n("]")).
12
+ gsub(%r{\s*\[\/TERMREF\]\s*}, l10n("]")).
8
13
  gsub(/\s*\[MODIFICATION\]/, l10n(", #{@modified_lbl} &mdash; "))
9
14
  end
10
15
 
16
+ def passthrough_cleanup(docxml)
17
+ docxml.split(%r{(<passthrough>|</passthrough>)}).each_slice(4).map do |a|
18
+ a.size > 2 and a[2] = HTMLEntities.new.decode(a[2])
19
+ [a[0], a[2]]
20
+ end.join
21
+ end
22
+
11
23
  def cleanup(docxml)
12
24
  comment_cleanup(docxml)
13
25
  footnote_cleanup(docxml)
@@ -118,7 +130,7 @@ module IsoDoc::Function
118
130
  end
119
131
 
120
132
  def footnote_cleanup(docxml)
121
- docxml.xpath('//a[@epub:type = "footnote"]/sup').each_with_index do |x, i|
133
+ docxml.xpath('//a[@class = "FootnoteRef"]/sup').each_with_index do |x, i|
122
134
  x.content = (i + 1).to_s
123
135
  end
124
136
  docxml
@@ -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
@@ -1,28 +1,7 @@
1
+ require_relative "inline_simple"
2
+
1
3
  module IsoDoc::Function
2
4
  module Inline
3
- def section_break(body)
4
- body.br
5
- end
6
-
7
- def page_break(out)
8
- out.br
9
- end
10
-
11
- def pagebreak_parse(_node, out)
12
- out.br
13
- end
14
-
15
- def hr_parse(node, out)
16
- out.hr
17
- end
18
-
19
- def br_parse(node, out)
20
- out.br
21
- end
22
-
23
- def index_parse(node, out)
24
- end
25
-
26
5
  def link_parse(node, out)
27
6
  out.a **attr_code(href: node["target"], title: node["alt"]) do |l|
28
7
  if node.text.empty?
@@ -38,29 +17,51 @@ module IsoDoc::Function
38
17
  end
39
18
 
40
19
  def prefix_container(container, linkend, _target)
41
- l10n(anchor(container, :xref) + ", " + linkend)
20
+ l10n(@xrefs.anchor(container, :xref) + ", " + linkend)
42
21
  end
43
22
 
44
23
  def anchor_linkend(node, linkend)
45
24
  if node["citeas"].nil? && node["bibitemid"]
46
- return anchor(node["bibitemid"] ,:xref) || "???"
25
+ return @xrefs.anchor(node["bibitemid"] ,:xref) || "???"
47
26
  elsif node["target"] && !/.#./.match(node["target"])
48
- linkend = anchor(node["target"], :xref)
49
- container = anchor(node["target"], :container, false)
27
+ linkend = @xrefs.anchor(node["target"], :xref)
28
+ container = @xrefs.anchor(node["target"], :container, false)
50
29
  (container && get_note_container_id(node) != container &&
51
- @anchors[node["target"]]) &&
30
+ @xrefs.get[node["target"]]) &&
52
31
  linkend = prefix_container(container, linkend, node["target"])
32
+ linkend = capitalise_xref(node, linkend)
53
33
  end
54
34
  linkend || "???"
55
35
  end
56
36
 
37
+ def capitalise_xref(node, linkend)
38
+ return linkend unless %w(Latn Cyrl Grek).include? @script
39
+ return linkend&.capitalize if node["case"] == "capital"
40
+ return linkend&.downcase if node["case"] == "lowercase"
41
+ return linkend if linkend[0,1].match(/\p{Upper}/)
42
+ prec = nearest_block_parent(node).xpath("./descendant-or-self::text()") &
43
+ node.xpath("./preceding::text()")
44
+ (prec.empty? || /(?!<[^.].)\.\s+$/.match(prec.map { |p| p.text }.join)) ?
45
+ linkend&.capitalize : linkend
46
+ end
47
+
48
+ def nearest_block_parent(node)
49
+ until %w(p title td th name formula
50
+ li dt dd sourcecode pre).include?(node.name)
51
+ node = node.parent
52
+ end
53
+ node
54
+ end
55
+
57
56
  def get_linkend(node)
58
- contents = node.children.select { |c| !%w{locality localityStack}.include? c.name }.
59
- select { |c| !c.text? || /\S/.match(c) }
57
+ contents = node.children.select do |c|
58
+ !%w{locality localityStack}.include? c.name
59
+ end.select { |c| !c.text? || /\S/.match(c) }
60
60
  !contents.empty? and
61
61
  return Nokogiri::XML::NodeSet.new(node.document, contents).to_xml
62
62
  link = anchor_linkend(node, docid_l10n(node["target"] || node["citeas"]))
63
- link + eref_localities(node.xpath(ns("./locality | ./localityStack")), link)
63
+ link + eref_localities(node.xpath(ns("./locality | ./localityStack")),
64
+ link)
64
65
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
65
66
  # <locality type="section"><reference>3.1</reference></locality></origin>
66
67
  end
@@ -83,27 +84,44 @@ module IsoDoc::Function
83
84
  end
84
85
  else
85
86
  ret += eref_localities0(r, i, target, delim)
86
- end
87
+ end
87
88
  end
88
89
  ret
89
90
  end
90
91
 
91
92
  def eref_localities0(r, i, target, delim)
92
- if r["type"] == "whole" then l10n("#{delim} #{@whole_of_text}")
93
+ if r["type"] == "whole" then l10n("#{delim} #{@wholeoftext_lbl}")
93
94
  else
94
95
  eref_localities1(target, r["type"], r.at(ns("./referenceFrom")),
95
96
  r.at(ns("./referenceTo")), delim, @lang)
96
97
  end
97
98
  end
98
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
+
99
116
  def eref_parse(node, out)
100
117
  linkend = get_linkend(node)
118
+ href = eref_target(node)
101
119
  if node["type"] == "footnote"
102
120
  out.sup do |s|
103
- s.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
121
+ s.a(**{ "href": href }) { |l| l << linkend }
104
122
  end
105
123
  else
106
- out.a(**{ "href": "#" + node["bibitemid"] }) { |l| l << linkend }
124
+ out.a(**{ "href": href }) { |l| l << linkend }
107
125
  end
108
126
  end
109
127
 
@@ -120,8 +138,9 @@ module IsoDoc::Function
120
138
  end
121
139
 
122
140
  def concept_parse(node, out)
123
- content = node.first_element_child.children.select { |c| !%w{locality localityStack}.include? c.name }.
124
- select { |c| !c.text? || /\S/.match(c) }
141
+ content = node.first_element_child.children.select do |c|
142
+ !%w{locality localityStack}.include? c.name
143
+ end.select { |c| !c.text? || /\S/.match(c) }
125
144
  if content.empty?
126
145
  out << "[Term defined in "
127
146
  parse(node.first_element_child, out)
@@ -133,7 +152,8 @@ module IsoDoc::Function
133
152
 
134
153
  def stem_parse(node, out)
135
154
  ooml = if node["type"] == "AsciiMath"
136
- "#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}#{@closemathdelim}"
155
+ "#{@openmathdelim}#{HTMLEntities.new.encode(node.text)}"\
156
+ "#{@closemathdelim}"
137
157
  elsif node["type"] == "MathML" then node.first_element_child.to_s
138
158
  else
139
159
  HTMLEntities.new.encode(node.text)
@@ -175,57 +195,31 @@ module IsoDoc::Function
175
195
  out << text
176
196
  end
177
197
 
178
- def bookmark_parse(node, out)
179
- out.a **attr_code(id: node["id"])
180
- end
181
-
182
- def keyword_parse(node, out)
183
- out.span **{ class: "keyword" } do |s|
184
- node.children.each { |n| parse(n, s) }
185
- end
186
- end
187
-
188
- def em_parse(node, out)
189
- out.i do |e|
190
- node.children.each { |n| parse(n, e) }
191
- end
192
- end
193
-
194
- def strong_parse(node, out)
195
- out.b do |e|
196
- node.children.each { |n| parse(n, e) }
197
- end
198
- end
199
-
200
- def sup_parse(node, out)
201
- out.sup do |e|
202
- node.children.each { |n| parse(n, e) }
203
- end
204
- end
205
-
206
- def sub_parse(node, out)
207
- out.sub do |e|
208
- node.children.each { |n| parse(n, e) }
209
- end
210
- end
211
-
212
- def tt_parse(node, out)
213
- out.tt do |e|
214
- node.children.each { |n| parse(n, e) }
198
+ def error_parse(node, out)
199
+ text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
200
+ out.para do |p|
201
+ p.b(**{ role: "strong" }) { |e| e << text }
215
202
  end
216
203
  end
217
204
 
218
- def strike_parse(node, out)
219
- out.s do |e|
220
- node.children.each { |n| parse(n, e) }
205
+ def variant_parse(node, out)
206
+ if node["lang"] == @lang && node["script"] == @script
207
+ node.children.each { |n| parse(n, out) }
208
+ else
209
+ return if found_matching_variant_sibling(node)
210
+ return unless !node.at("./preceding-sibling::xmlns:variant")
211
+ node.children.each { |n| parse(n, out) }
221
212
  end
222
213
  end
223
214
 
224
- def error_parse(node, out)
225
- text = node.to_xml.gsub(/</, "&lt;").gsub(/>/, "&gt;")
226
- out.para do |p|
227
- p.b(**{ role: "strong" }) { |e| e << text }
215
+ def found_matching_variant_sibling(node)
216
+ prev = node.xpath("./preceding-sibling::xmlns:variant")
217
+ foll = node.xpath("./following-sibling::xmlns:variant")
218
+ found = false
219
+ (prev + foll).each do |n|
220
+ found = true if n["lang"] == @lang && n["script"] == @script
228
221
  end
222
+ found
229
223
  end
230
224
  end
231
225
  end
@@ -0,0 +1,72 @@
1
+ module IsoDoc::Function
2
+ module Inline
3
+ def section_break(body)
4
+ body.br
5
+ end
6
+
7
+ def page_break(out)
8
+ out.br
9
+ end
10
+
11
+ def pagebreak_parse(_node, out)
12
+ out.br
13
+ end
14
+
15
+ def hr_parse(node, out)
16
+ out.hr
17
+ end
18
+
19
+ def br_parse(node, out)
20
+ out.br
21
+ end
22
+
23
+ def index_parse(node, out)
24
+ end
25
+
26
+ def bookmark_parse(node, out)
27
+ out.a **attr_code(id: node["id"])
28
+ end
29
+
30
+ def keyword_parse(node, out)
31
+ out.span **{ class: "keyword" } do |s|
32
+ node.children.each { |n| parse(n, s) }
33
+ end
34
+ end
35
+
36
+ def em_parse(node, out)
37
+ out.i do |e|
38
+ node.children.each { |n| parse(n, e) }
39
+ end
40
+ end
41
+
42
+ def strong_parse(node, out)
43
+ out.b do |e|
44
+ node.children.each { |n| parse(n, e) }
45
+ end
46
+ end
47
+
48
+ def sup_parse(node, out)
49
+ out.sup do |e|
50
+ node.children.each { |n| parse(n, e) }
51
+ end
52
+ end
53
+
54
+ def sub_parse(node, out)
55
+ out.sub do |e|
56
+ node.children.each { |n| parse(n, e) }
57
+ end
58
+ end
59
+
60
+ def tt_parse(node, out)
61
+ out.tt do |e|
62
+ node.children.each { |n| parse(n, e) }
63
+ end
64
+ end
65
+
66
+ def strike_parse(node, out)
67
+ out.s do |e|
68
+ node.children.each { |n| parse(n, e) }
69
+ end
70
+ end
71
+ end
72
+ end
@@ -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)
@@ -5,30 +5,31 @@ module IsoDoc::Function
5
5
  # references anyway; keeping here instead of in IsoDoc::Iso for now
6
6
  def docid_l10n(x)
7
7
  return x if x.nil?
8
- x.gsub(/All Parts/i, @all_parts_lbl.downcase)
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
12
- def nonstd_bibitem(list, b, ordinal, bibliography)
13
- list.p **attr_code(iso_bibitem_entry_attrs(b, bibliography)) do |r|
14
- id = bibitem_ref_code(b)
15
- identifier = render_identifier(id)
16
- if bibliography then ref_entry_code(r, ordinal, identifier, id)
13
+ def nonstd_bibitem(list, b, ordinal, biblio)
14
+ list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
15
+ ids = bibitem_ref_code(b)
16
+ identifiers = render_identifier(ids)
17
+ if biblio then ref_entry_code(ref, ordinal, identifiers, ids)
17
18
  else
18
- identifier = "[#{identifier}]" if id["type"] == "metanorma"
19
- r << "#{identifier}, "
19
+ ref << "#{identifiers[0] || identifiers[1]}, "
20
+ ref << "#{identifiers[1]}, " if identifiers[0] && identifiers[1]
20
21
  end
21
- reference_format(b, r)
22
+ reference_format(b, ref)
22
23
  end
23
24
  end
24
25
 
25
26
  def std_bibitem_entry(list, b, ordinal, biblio)
26
27
  list.p **attr_code(iso_bibitem_entry_attrs(b, biblio)) do |ref|
27
- prefix_bracketed_ref(ref, ordinal) if biblio
28
- id = bibitem_ref_code(b)
29
- identifier = render_identifier(id)
30
- identifier = "[#{identifier}]" if id["type"] == "metanorma" && !biblio
31
- ref << identifier
28
+ ids = bibitem_ref_code(b)
29
+ identifiers = render_identifier(ids)
30
+ prefix_bracketed_ref(ref, "[#{ordinal}]") if biblio
31
+ ref << "#{identifiers[0] || identifiers[1]}"
32
+ ref << ", #{identifiers[1]}" if identifiers[0] && identifiers[1]
32
33
  date_note_process(b, ref)
33
34
  ref << ", "
34
35
  reference_format(b, ref)
@@ -38,29 +39,43 @@ module IsoDoc::Function
38
39
  # if t is just a number, only use that ([1] Non-Standard)
39
40
  # else, use both ordinal, as prefix, and t
40
41
  def ref_entry_code(r, ordinal, t, id)
41
- if id["type"] == "metanorma"
42
- prefix_bracketed_ref(r, t)
43
- else
44
- prefix_bracketed_ref(r, ordinal)
45
- if !t.empty? && !%w(DOI ISSN ISBN).include?(id["type"])
46
- r << "#{t}, "
47
- end
42
+ prefix_bracketed_ref(r, t[0] || "[#{ordinal}]")
43
+ if t[1]
44
+ r << "#{t[1]}, "
48
45
  end
49
46
  end
50
47
 
48
+ def pref_ref_code(b)
49
+ b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
50
+ "or @type = 'ISSN' or @type = 'ISBN' or @type = 'rfc-anchor')]"))
51
+ end
52
+
53
+ # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
51
54
  def bibitem_ref_code(b)
52
55
  id = b.at(ns("./docidentifier[@type = 'metanorma']"))
53
- id ||= b.at(ns("./docidentifier[not(@type = 'DOI' or @type = 'metanorma' "\
54
- "or @type = 'ISSN' or @type = 'ISBN')]"))
55
- id ||= b.at(ns("./docidentifier"))
56
- return id if id
56
+ id1 = pref_ref_code(b)
57
+ id2 = b.at(ns("./docidentifier[@type = 'DOI' or @type = 'ISSN' or @type = 'ISBN']"))
58
+ return [id, id1, id2] if id || id1 || id2
57
59
  id = Nokogiri::XML::Node.new("docidentifier", b.document)
58
60
  id << "(NO ID)"
59
- id
61
+ [nil, id, nil]
62
+ end
63
+
64
+ def bracket_if_num(x)
65
+ return nil if x.nil?
66
+ x = x.text.sub(/^\[/, "").sub(/\]$/, "")
67
+ return "[#{x}]" if /^\d+$/.match(x)
68
+ x
60
69
  end
61
70
 
62
71
  def render_identifier(id)
63
- docid_prefix(id["type"], id.text.sub(/^\[/, "").sub(/\]$/, ""))
72
+ [
73
+ bracket_if_num(id[0]),
74
+ id[1].nil? ? nil :
75
+ docid_prefix(id[1]["type"], id[1].text.sub(/^\[/, "").sub(/\]$/, "")),
76
+ id[2].nil? ? nil :
77
+ docid_prefix(id[2]["type"], id[2].text.sub(/^\[/, "").sub(/\]$/, "")),
78
+ ]
64
79
  end
65
80
 
66
81
  def docid_prefix(prefix, docid)
@@ -70,13 +85,12 @@ module IsoDoc::Function
70
85
 
71
86
  def omit_docid_prefix(prefix)
72
87
  return true if prefix.nil? || prefix.empty?
73
- return %w(ISO IEC ITU metanorma).include? prefix
88
+ return %w(ISO IEC ITU W3C metanorma).include? prefix
74
89
  end
75
90
 
76
91
  def date_note_process(b, ref)
77
- date_note = b.at(ns("./note[text()][contains(.,'ISO DATE:')]"))
92
+ date_note = b.at(ns("./note[@type = 'ISO DATE']"))
78
93
  return if date_note.nil?
79
- date_note.content = date_note.content.gsub(/ISO DATE: /, "")
80
94
  date_note.children.first.replace("<p>#{date_note.content}</p>")
81
95
  footnote_parse(date_note, ref)
82
96
  end
@@ -100,7 +114,7 @@ module IsoDoc::Function
100
114
  end
101
115
 
102
116
  def prefix_bracketed_ref(ref, text)
103
- ref << "[#{text}]"
117
+ ref << text.to_s
104
118
  insert_tab(ref, 1)
105
119
  end
106
120
 
@@ -115,12 +129,6 @@ module IsoDoc::Function
115
129
  end
116
130
  end
117
131
 
118
- ISO_PUBLISHER_XPATH =
119
- "./contributor[xmlns:role/@type = 'publisher']/"\
120
- "organization[abbreviation = 'ISO' or xmlns:abbreviation = 'IEC' or "\
121
- "xmlns:name = 'International Organization for Standardization' or "\
122
- "xmlns:name = 'International Electrotechnical Commission']".freeze
123
-
124
132
  def is_standard(b)
125
133
  ret = false
126
134
  b.xpath(ns("./docidentifier")).each do |id|
@@ -146,8 +154,7 @@ module IsoDoc::Function
146
154
  end
147
155
 
148
156
  def norm_ref(isoxml, out, num)
149
- q = "//bibliography/references[title = 'Normative References' or "\
150
- "title = 'Normative references']"
157
+ q = "//bibliography/references[@normative = 'true']"
151
158
  f = isoxml.at(ns(q)) or return num
152
159
  out.div do |div|
153
160
  num = num + 1
@@ -157,8 +164,8 @@ module IsoDoc::Function
157
164
  num
158
165
  end
159
166
 
160
- BIBLIOGRAPHY_XPATH = "//bibliography/clause[title = 'Bibliography'] | "\
161
- "//bibliography/references[title = 'Bibliography']".freeze
167
+ BIBLIOGRAPHY_XPATH = "//bibliography/clause[.//references[@normative = 'false']] | "\
168
+ "//bibliography/references[@normative = 'false']".freeze
162
169
 
163
170
  def bibliography(isoxml, out)
164
171
  f = isoxml.at(ns(BIBLIOGRAPHY_XPATH)) || return
@@ -172,7 +179,7 @@ module IsoDoc::Function
172
179
  def bibliography_parse(node, out)
173
180
  title = node&.at(ns("./title"))&.text || ""
174
181
  out.div do |div|
175
- anchor(node['id'], :label, false) and
182
+ @xrefs.anchor(node['id'], :label, false) and
176
183
  clause_parse_title(node, div, node.at(ns("./title")), out) or
177
184
  div.h2 title, **{ class: "Section3" }
178
185
  biblio_list(node, div, true)
@@ -186,17 +193,6 @@ module IsoDoc::Function
186
193
  ref
187
194
  end
188
195
 
189
- def reference_names(ref)
190
- isopub = ref.at(ns(ISO_PUBLISHER_XPATH))
191
- docid = bibitem_ref_code(ref)
192
- prefix = docid["type"]
193
- date = ref.at(ns("./date[@type = 'published']"))
194
- allparts = ref.at(ns("./extent[@type='part'][referenceFrom='all']"))
195
- reference = format_ref(docid_l10n(docid.text), prefix, isopub, date,
196
- allparts)
197
- @anchors[ref["id"]] = { xref: reference }
198
- end
199
-
200
196
  # def ref_names(ref)
201
197
  # linkend = ref.text
202
198
  # linkend.gsub!(/[\[\]]/, "") unless /^\[\d+\]$/.match linkend