isodoc 2.11.4 → 2.12.1

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -1
  3. data/lib/isodoc/function/blocks.rb +12 -41
  4. data/lib/isodoc/function/blocks_example_note.rb +37 -14
  5. data/lib/isodoc/function/cleanup.rb +3 -40
  6. data/lib/isodoc/function/inline.rb +8 -1
  7. data/lib/isodoc/function/lists.rb +1 -1
  8. data/lib/isodoc/function/references.rb +4 -128
  9. data/lib/isodoc/function/section.rb +1 -4
  10. data/lib/isodoc/function/section_titles.rb +1 -1
  11. data/lib/isodoc/function/table.rb +2 -2
  12. data/lib/isodoc/function/terms.rb +8 -10
  13. data/lib/isodoc/function/to_word_html.rb +3 -5
  14. data/lib/isodoc/function/utils.rb +1 -1
  15. data/lib/isodoc/init.rb +21 -0
  16. data/lib/isodoc/metadata.rb +1 -1
  17. data/lib/isodoc/presentation_function/block.rb +58 -8
  18. data/lib/isodoc/presentation_function/docid.rb +101 -0
  19. data/lib/isodoc/presentation_function/erefs.rb +2 -2
  20. data/lib/isodoc/presentation_function/image.rb +31 -8
  21. data/lib/isodoc/presentation_function/inline.rb +5 -5
  22. data/lib/isodoc/presentation_function/math.rb +0 -14
  23. data/lib/isodoc/presentation_function/metadata.rb +0 -62
  24. data/lib/isodoc/presentation_function/refs.rb +44 -14
  25. data/lib/isodoc/presentation_function/section.rb +12 -15
  26. data/lib/isodoc/presentation_function/terms.rb +27 -1
  27. data/lib/isodoc/presentation_xml_convert.rb +4 -1
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/body.rb +3 -3
  30. data/lib/isodoc/xref/clause_order.rb +2 -2
  31. data/lib/isodoc/xref/xref_anchor.rb +1 -1
  32. data/lib/isodoc/xref/xref_counter.rb +18 -3
  33. data/lib/isodoc/xref/xref_counter_types.rb +13 -0
  34. data/lib/isodoc/xref/xref_gen.rb +6 -7
  35. data/lib/isodoc/xref/xref_sect_gen.rb +16 -31
  36. data/lib/isodoc/xref/xref_util.rb +6 -0
  37. data/lib/isodoc/xref.rb +26 -10
  38. data/lib/isodoc-yaml/i18n-ja.yaml +13 -13
  39. metadata +6 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9890e0801befbe1a13b4138f01f702537e46d4cc482ac99f03f1faf1e7ac532b
4
- data.tar.gz: 69ba3b17b78d0a464cae75213d0eadca3047d0cb7c55a148db7d014b25f2bbd0
3
+ metadata.gz: 1936cca0c61f789903af805b809d73c8dbae298e4bc6569c533274dbf5d8eac5
4
+ data.tar.gz: 3bc62ddb747526969bf2c36d10ffab8e0b0008e827ee7b6634f566c925d5db8c
5
5
  SHA512:
6
- metadata.gz: 1db6e8c07945fb2ad57b19094279d0e26f8638e1e6fefaa261ec9230438dfaf0cea0c7ec6b49276f4108332d41d875c23fd8aa57295bdbbaaee88846f1375ce2
7
- data.tar.gz: 0e127ca60d5841b344d0e3b399475fb5adfb9b72b4df6ae5a2943df95b39f40ab56f486f3eae669b26b2fd239e13d02503e97834fea758575324af7795ca2584
6
+ metadata.gz: a3f526f015973c666f70749ee97708d992c455d9d0d8273cb8389f73090a9926f66cdb616d1d2b13f2737ab53248103674cf34bec46ab5cff42f3bd678bb43b9
7
+ data.tar.gz: cf3c0a4afbc963c4ab579bf36ab252030f882f794b8b27e734b58f8e8d4c99a6e9b40b283e8dd1d089cb1b9d16aeb9d47e3040cbfb84014e2f60a1a4150b4c15
data/isodoc.gemspec CHANGED
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
34
34
  # spec.add_dependency "isodoc-i18n", "~> 1.1.0" # already in relaton-render and mn-requirements
35
35
  # spec.add_dependency "relaton-cli"
36
36
  # spec.add_dependency "metanorma-utils", "~> 1.5.0" # already in isodoc-i18n
37
- spec.add_dependency "mn2pdf"
37
+ spec.add_dependency "mn2pdf", ">= 2.08"
38
38
  spec.add_dependency "mn-requirements", "~> 0.4.0"
39
39
 
40
40
  spec.add_dependency "relaton-render", "~> 0.7.1"
@@ -3,8 +3,6 @@ require_relative "blocks_example_note"
3
3
  module IsoDoc
4
4
  module Function
5
5
  module Blocks
6
- @annotation = false
7
-
8
6
  def figure_name_parse(_node, div, name)
9
7
  name.nil? and return
10
8
  div.p class: "FigureTitle", style: "text-align:center;" do |p|
@@ -12,20 +10,13 @@ module IsoDoc
12
10
  end
13
11
  end
14
12
 
15
- def figure_key(out)
16
- out.p style: "page-break-after:avoid;" do |p|
17
- p.b { |b| b << @i18n.key }
18
- end
19
- end
20
-
21
13
  def figure_attrs(node)
22
14
  attr_code(id: node["id"], class: "figure", style: keep_style(node))
23
15
  end
24
16
 
25
17
  def figure_parse(node, out)
26
- return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
27
- node["type"] == "pseudocode"
28
-
18
+ node["class"] == "pseudocode" || node["type"] == "pseudocode" and
19
+ return pseudocode_parse(node, out)
29
20
  @in_figure = true
30
21
  figure_parse1(node, out)
31
22
  @in_figure = false
@@ -34,7 +25,6 @@ module IsoDoc
34
25
  def figure_parse1(node, out)
35
26
  out.div **figure_attrs(node) do |div|
36
27
  node.children.each do |n|
37
- figure_key(out) if n.name == "dl"
38
28
  parse(n, div) unless n.name == "name"
39
29
  end
40
30
  figure_name_parse(node, div, node.at(ns("./name")))
@@ -56,8 +46,7 @@ module IsoDoc
56
46
  end
57
47
 
58
48
  def sourcecode_name_parse(_node, div, name)
59
- return if name.nil?
60
-
49
+ name.nil? and return
61
50
  div.p class: "SourceTitle", style: "text-align:center;" do |p|
62
51
  name.children.each { |n| parse(n, p) }
63
52
  end
@@ -95,10 +84,8 @@ module IsoDoc
95
84
  def annotation_parse(node, out)
96
85
  dl = node.at(ns("./dl")) or return
97
86
  @sourcecode = false
98
- # @annotation = true
99
87
  out.div class: "annotation" do |div|
100
88
  parse(dl, div)
101
- # @annotation = false
102
89
  end
103
90
  end
104
91
 
@@ -108,7 +95,7 @@ module IsoDoc
108
95
  parse(node.at(ns("./stem")), div)
109
96
  if lbl = node&.at(ns("./name"))&.text
110
97
  insert_tab(div, 1)
111
- div << "(#{lbl})"
98
+ div << lbl
112
99
  end
113
100
  end
114
101
  end
@@ -122,8 +109,7 @@ module IsoDoc
122
109
  out.div **formula_attrs(node) do |div|
123
110
  formula_parse1(node, div)
124
111
  node.children.each do |n|
125
- next if %w(stem name).include? n.name
126
-
112
+ %w(stem name).include? n.name and next
127
113
  parse(n, div)
128
114
  end
129
115
  end
@@ -132,10 +118,8 @@ module IsoDoc
132
118
  def para_class(node)
133
119
  classtype = nil
134
120
  classtype = "MsoCommentText" if in_comment
135
- classtype = "Sourcecode" if @annotation
136
- if node["type"] == "floating-title"
121
+ node["type"] == "floating-title" and
137
122
  classtype = "h#{node['depth']}"
138
- end
139
123
  classtype ||= node["class"]
140
124
  classtype
141
125
  end
@@ -150,22 +134,13 @@ module IsoDoc
150
134
 
151
135
  def para_parse(node, out)
152
136
  out.p **attr_code(para_attrs(node)) do |p|
153
- unless @termdomain.empty?
154
- p << "&lt;#{@termdomain}&gt; "
155
- @termdomain = ""
156
- end
157
137
  node.children.each { |n| parse(n, p) }
158
138
  end
159
139
  end
160
140
 
161
- def quote_attribution(node, out)
162
- author = node.at(ns("./author"))
163
- source = node.at(ns("./source"))
164
- author.nil? && source.nil? and return
165
- out.p class: "QuoteAttribution" do |p|
166
- p << "&#x2014; #{author.text}" if author
167
- p << ", " if author && source
168
- eref_parse(source, p) if source
141
+ def attribution_parse(node, out)
142
+ out.div class: "QuoteAttribution" do |d|
143
+ node.children.each { |n| parse(n, d) }
169
144
  end
170
145
  end
171
146
 
@@ -173,17 +148,13 @@ module IsoDoc
173
148
  attrs = para_attrs(node)
174
149
  attrs[:class] = "Quote"
175
150
  out.div **attr_code(attrs) do |p|
176
- node.children.each do |n|
177
- parse(n, p) unless %w(author source).include? n.name
178
- end
179
- quote_attribution(node, out)
151
+ node.children.each { |n| parse(n, p) }
180
152
  end
181
153
  end
182
154
 
183
155
  def passthrough_parse(node, out)
184
- return if node["format"] &&
185
- !(node["format"].split(",").include? @format.to_s)
186
-
156
+ node["formats"] &&
157
+ !(node["formats"].split(" ").include? @format.to_s) and return
187
158
  out.passthrough node.text
188
159
  end
189
160
 
@@ -2,8 +2,7 @@ module IsoDoc
2
2
  module Function
3
3
  module Blocks
4
4
  def example_label(_node, div, name)
5
- return if name.nil?
6
-
5
+ name.nil? and return
7
6
  div.p class: "example-title" do |_p|
8
7
  name.children.each { |n| parse(n, div) }
9
8
  end
@@ -53,28 +52,22 @@ module IsoDoc
53
52
  example_div_parse(node, out)
54
53
  end
55
54
 
56
- def note_delim
57
- ""
58
- end
59
-
60
55
  def note_p_parse(node, div)
61
56
  name = node.at(ns("./name"))&.remove
62
57
  div.p do |p|
63
58
  name and p.span class: "note_label" do |s|
64
59
  name.children.each { |n| parse(n, s) }
65
- s << note_delim
66
60
  end
67
61
  insert_tab(p, 1)
68
62
  node.first_element_child.children.each { |n| parse(n, p) }
69
63
  end
70
- node.element_children[1..-1].each { |n| parse(n, div) }
64
+ node.element_children[1..].each { |n| parse(n, div) }
71
65
  end
72
66
 
73
67
  def note_parse1(node, div)
74
68
  name = node.at(ns("./name")) and div.p do |p|
75
69
  p.span class: "note_label" do |s|
76
70
  name.remove.children.each { |n| parse(n, s) }
77
- s << note_delim
78
71
  end
79
72
  insert_tab(p, 1)
80
73
  end
@@ -130,12 +123,42 @@ module IsoDoc
130
123
  end
131
124
 
132
125
  def admonition_parse(node, out)
133
- type = node["type"]
134
- name = admonition_name(node, type)
135
- out.div **admonition_attrs(node) do |t|
136
- admonition_name_parse(node, t, name) if name
137
- node.children.each { |n| parse(n, t) unless n.name == "name" }
126
+ out.div **admonition_attrs(node) do |div|
127
+ if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p"
128
+ admonition_p_parse(node, div)
129
+ else
130
+ admonition_parse1(node, div)
131
+ end
132
+ end
133
+ end
134
+
135
+ # code to allow name and first paragraph to be rendered in same block
136
+ def admonition_p_parse(node, div)
137
+ admonition_parse1(node, div)
138
+ end
139
+
140
+ # code to allow name and first paragraph to be rendered in same block
141
+ def admonition_name_in_first_para(node, div)
142
+ div.p do |p|
143
+ if name = admonition_name(node, node["type"])&.remove
144
+ name.children.each { |n| parse(n, p) }
145
+ admonition_name_para_delim(p)
146
+ end
147
+ node.first_element_child.children.each { |n| parse(n, p) }
148
+ end
149
+ node.element_children[1..].each { |n| parse(n, div) }
150
+ end
151
+
152
+ def admonition_name_para_delim(para)
153
+ insert_tab(para, 1)
154
+ end
155
+
156
+ def admonition_parse1(node, div)
157
+ name = admonition_name(node, node["type"])
158
+ if name
159
+ admonition_name_parse(node, div, name)
138
160
  end
161
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
139
162
  end
140
163
  end
141
164
  end
@@ -25,6 +25,7 @@ module IsoDoc
25
25
  admonition_cleanup(docxml)
26
26
  end
27
27
 
28
+ # todo PRESENTATION XML
28
29
  def admonition_cleanup(docxml)
29
30
  docxml.xpath("//div[@class = 'Admonition'][title]").each do |d|
30
31
  title = d.at("./title")
@@ -42,45 +43,7 @@ module IsoDoc
42
43
  docxml
43
44
  end
44
45
 
45
- def figure_get_or_make_dl(elem)
46
- dl = elem.at(".//dl")
47
- if dl.nil?
48
- elem.add_child("<p><b>#{@i18n.key}</b></p><dl></dl>")
49
- dl = elem.at(".//dl")
50
- end
51
- dl
52
- end
53
-
54
- FIGURE_WITH_FOOTNOTES =
55
- "//div[@class = 'figure'][descendant::aside]" \
56
- "[not(descendant::div[@class = 'figure'])]".freeze
57
-
58
- def figure_aside_process(elem, aside, key)
59
- # get rid of footnote link, it is in diagram
60
- elem&.at("./a[@class='TableFootnoteRef']")&.remove
61
- fnref = elem.at(".//span[@class='TableFootnoteRef']/..")
62
- dt = key.add_child("<dt></dt>").first
63
- dd = key.add_child("<dd></dd>").first
64
- fnref.parent = dt
65
- aside.xpath(".//p").each do |a|
66
- a.delete("class")
67
- a.parent = dd
68
- end
69
- end
70
-
71
- # move footnotes into key, and get rid of footnote reference
72
- # since it is in diagram
73
- def figure_cleanup(docxml)
74
- docxml.xpath(FIGURE_WITH_FOOTNOTES).each do |f|
75
- next unless f.at(".//aside[not(ancestor::p[@class = 'FigureTitle'])]")
76
-
77
- key = figure_get_or_make_dl(f)
78
- f.xpath(".//aside").each do |aside|
79
- figure_aside_process(f, aside, key)
80
- end
81
- end
82
- docxml
83
- end
46
+ def figure_cleanup(docxml); end
84
47
 
85
48
  def inline_header_cleanup(docxml)
86
49
  docxml.xpath('//span[@class="zzMoveToFollowing"]').each do |x|
@@ -89,13 +52,13 @@ module IsoDoc
89
52
  if n.nil?
90
53
  x.name = "p"
91
54
  else
92
- #n.children.first.previous = x.remove
93
55
  n.add_first_child(x.remove)
94
56
  end
95
57
  end
96
58
  docxml
97
59
  end
98
60
 
61
+ # todo PRESENTATION XML
99
62
  def footnote_cleanup(docxml)
100
63
  docxml.xpath('//a[@class = "FootnoteRef"]/sup')
101
64
  .each_with_index do |x, i|
@@ -8,7 +8,8 @@ module IsoDoc
8
8
  node["update-type"] == "true" and url = suffix_url(url)
9
9
  out.a **attr_code(href: url, title: node["alt"]) do |l|
10
10
  if node.elements.empty? && node.text.strip.empty?
11
- l << @c.encode(node["target"].sub(/^mailto:/, ""), :basic, :hexadecimal)
11
+ l << @c.encode(node["target"].sub(/^mailto:/, ""), :basic,
12
+ :hexadecimal)
12
13
  else node.children.each { |n| parse(n, l) }
13
14
  end
14
15
  end
@@ -26,6 +27,7 @@ module IsoDoc
26
27
  end
27
28
  end
28
29
 
30
+ # todo PRESENTATION XML
29
31
  def callout_parse(node, out)
30
32
  out << " &lt;#{node.text}&gt;"
31
33
  end
@@ -64,6 +66,7 @@ module IsoDoc
64
66
  end
65
67
  end
66
68
 
69
+ # todo PRESENTATION XML
67
70
  def termrefelem_parse(node, out)
68
71
  if node.text.strip.empty?
69
72
  out << "Termbase #{node['base']}, term ID #{node['target']}"
@@ -179,6 +182,10 @@ module IsoDoc
179
182
  node.children.each { |n| parse(n, e) }
180
183
  end
181
184
  end
185
+
186
+ def author_parse(node, out)
187
+ node.children.each { |n| parse(n, out) }
188
+ end
182
189
  end
183
190
  end
184
191
  end
@@ -4,7 +4,7 @@ module IsoDoc
4
4
  def list_title_parse(node, out)
5
5
  name = node.at(ns("./name")) or return
6
6
  out.p class: "ListTitle" do |p|
7
- name&.children&.each { |n| parse(n, p) }
7
+ name.children&.each { |n| parse(n, p) }
8
8
  end
9
9
  end
10
10
 
@@ -1,16 +1,7 @@
1
1
  module IsoDoc
2
2
  module Function
3
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
- text.nil? and return text
8
- @i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
9
- text.size < 20 and text.gsub!(/ /, "&#xa0;")
10
- text
11
- end
12
-
13
- def nonstd_bibitem(list, bib, _ordinal, biblio)
4
+ def bibitem_entry(list, bib, _ordinal, biblio)
14
5
  list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
15
6
  tag = bib.at(ns("./biblio-tag"))
16
7
  tag&.children&.each { |n| parse(n, ref) }
@@ -18,137 +9,22 @@ module IsoDoc
18
9
  end
19
10
  end
20
11
 
21
- def std_bibitem_entry(list, bib, _ordinal, biblio)
22
- list.p **attr_code(iso_bibitem_entry_attrs(bib, biblio)) do |ref|
23
- tag = bib.at(ns("./biblio-tag"))
24
- tag&.children&.each { |n| parse(n, ref) }
25
- reference_format(bib, ref)
26
- end
27
- end
28
-
29
- SKIP_DOCID = <<~XPATH.strip.freeze
30
- @type = 'DOI' or @type = 'doi' or @type = 'ISSN' or @type = 'issn' or @type = 'ISBN' or @type = 'isbn' or starts-with(@type, 'ISSN.') or starts-with(@type, 'ISBN.') or starts-with(@type, 'issn.') or starts-with(@type, 'isbn.')
31
- XPATH
32
-
33
- def pref_ref_code(bib)
34
- bib["suppress_identifier"] == "true" and return nil
35
- ret = bib.xpath(ns("./docidentifier[@scope = 'biblio-tag']"))
36
- ret.empty? or return ret.map(&:text)
37
- ret = pref_ref_code_parse(bib) or return nil
38
- ins = bib.at(ns("./docidentifier[last()]"))
39
- ret.reverse.each do |r|
40
- ins.next = "<docidentifier scope='biblio-tag'>#{docid_l10n(r)}</docidentifier>"
41
- end
42
- ret
43
- end
44
-
45
- def pref_ref_code_parse(bib)
46
- data, = @bibrender.parse(bib)
47
- ret = data[:authoritative_identifier] or return nil
48
- ret.empty? and return nil
49
- ret
50
- end
51
-
52
- # returns [metanorma, non-metanorma, DOI/ISSN/ISBN] identifiers
53
- def bibitem_ref_code(bib)
54
- id, id1, id2, id3 = bibitem_ref_code_prep(bib)
55
- id || id1 || id2 || id3 and return [id, id1, id2, id3]
56
- bib["suppress_identifier"] == "true" and return [nil, nil, nil, nil]
57
- [nil, no_identifier(bib), nil, nil]
58
- end
59
-
60
- def bibitem_ref_code_prep(bib)
61
- id = bib.at(ns("./docidentifier[@type = 'metanorma']"))
62
- id1 = pref_ref_code(bib)
63
- id2 = bib.at(ns("./docidentifier[#{SKIP_DOCID}]"))
64
- id3 = bib.at(ns("./docidentifier[@type = 'metanorma-ordinal']"))
65
- [id, id1, id2, id3]
66
- end
67
-
68
- def no_identifier(bib)
69
- @i18n.no_identifier or return nil
70
- id = Nokogiri::XML::Node.new("docidentifier", bib.document)
71
- id << @i18n.no_identifier
72
- id
73
- end
74
-
75
- def bracket_if_num(num)
76
- num.nil? and return nil
77
- num = num.text.sub(/^\[/, "").sub(/\]$/, "")
78
- /^\d+$/.match?(num) and return "[#{num}]"
79
- num
80
- end
81
-
82
- def unbracket1(ident)
83
- ident.nil? and return nil
84
- ident.is_a?(String) or ident = ident.text
85
- ident.sub(/^\[/, "").sub(/\]$/, "")
86
- end
87
-
88
- def unbracket(ident)
89
- if ident.respond_to?(:size)
90
- ident.map { |x| unbracket1(x) }.join("&#xA0;/ ")
91
- else
92
- unbracket1(ident)
93
- end
94
- end
95
-
96
- def render_identifier(ident)
97
- { metanorma: bracket_if_num(ident[0]),
98
- sdo: unbracket(ident[1]),
99
- doi: unbracket(ident[2]),
100
- ordinal: bracket_if_num(ident[3]) }
101
- end
102
-
103
- def docid_prefix(prefix, docid)
104
- docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
105
- !/^#{prefix}\b/.match(docid)
106
- docid_l10n(docid)
107
- end
108
-
109
- def omit_docid_prefix(prefix)
110
- return true if prefix.nil? || prefix.empty?
111
-
112
- %w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
113
- .include? prefix
114
- end
115
-
116
12
  def iso_bibitem_entry_attrs(bib, biblio)
117
13
  { id: bib["id"], class: biblio ? "Biblio" : "NormRef" }
118
14
  end
119
15
 
120
- # reference not to be rendered because it is deemed implicit
121
- # in the standards environment
122
- def implicit_reference(bib)
123
- bib["hidden"] == "true"
124
- end
125
-
126
16
  def reference_format(bib, out)
127
17
  ftitle = bib.at(ns("./formattedref"))
128
18
  ftitle&.children&.each { |n| parse(n, out) }
129
19
  end
130
20
 
131
- def standard?(bib)
132
- ret = false
133
- bib.xpath(ns("./docidentifier")).each do |id|
134
- next if id["type"].nil? ||
135
- id.at(".//self::*[#{SKIP_DOCID} or @type = 'metanorma']")
136
-
137
- ret = true
138
- end
139
- ret
140
- end
141
-
142
21
  def biblio_list(refs, div, biblio)
143
22
  i = 0
144
23
  refs.children.each do |b|
145
24
  if b.name == "bibitem"
146
- next if implicit_reference(b)
147
-
148
- i += 1 unless b["hidden"]
149
- if standard?(b) then std_bibitem_entry(div, b, i, biblio)
150
- else nonstd_bibitem(div, b, i, biblio)
151
- end
25
+ b["hidden"] == "true" and next
26
+ i += 1
27
+ bibitem_entry(div, b, i, biblio)
152
28
  else
153
29
  parse(b, div) unless %w(title).include? b.name
154
30
  end
@@ -82,9 +82,6 @@ module IsoDoc
82
82
 
83
83
  # subclause
84
84
  def symbols_parse(isoxml, out)
85
- isoxml.at(ns("./title")) or
86
- #isoxml.children.first.previous = "<title>#{@i18n.symbols}</title>"
87
- isoxml.add_first_child "<title>#{@i18n.symbols}</title>"
88
85
  clause_parse(isoxml, out)
89
86
  end
90
87
 
@@ -102,7 +99,7 @@ module IsoDoc
102
99
  def foreword(clause, out)
103
100
  page_break(out)
104
101
  out.div **attr_code(id: clause["id"]) do |s|
105
- clause_name(clause, clause.at(ns("./title")) || @i18n.foreword, s,
102
+ clause_name(clause, clause.at(ns("./title")), s,
106
103
  { class: "ForewordTitle" })
107
104
  clause.elements.each { |e| parse(e, s) unless e.name == "title" }
108
105
  end
@@ -63,7 +63,7 @@ module IsoDoc
63
63
  end
64
64
 
65
65
  # top level clause names
66
- def clause_name(node, title, div, header_class)
66
+ def clause_name(_node, title, div, header_class)
67
67
  header_class = {} if header_class.nil?
68
68
  div.h1 **attr_code(header_class) do |h1|
69
69
  if title.is_a?(String) then h1 << title
@@ -112,12 +112,12 @@ module IsoDoc
112
112
  !header && cell.name == "th" and
113
113
  scope = (cell["rowspan"] ? "rowgroup" : "row")
114
114
  { rowspan: cell["rowspan"], colspan: cell["colspan"],
115
- style: style.gsub(/\n/, ""), scope: scope, class: cell["class"] }
115
+ style: style.delete("\n"), scope: scope, class: cell["class"] }
116
116
  end
117
117
 
118
118
  def make_tr_attr_style(row, rowmax, totalrows, _header, bordered)
119
119
  bordered or return ""
120
- <<~STYLE.gsub(/\n/, "")
120
+ <<~STYLE.delete("\n")
121
121
  border-top:#{row.zero? ? "#{SW} 1.5pt;" : 'none;'}
122
122
  border-bottom:#{SW} #{rowmax >= totalrows ? '1.5' : '1.0'}pt;
123
123
  STYLE
@@ -37,18 +37,12 @@ module IsoDoc
37
37
  end
38
38
  end
39
39
 
40
- def termnote_delim
41
- l10n(": ")
42
- end
43
-
44
40
  def termnote_parse(node, out)
45
41
  name = node&.at(ns("./name"))&.remove
46
42
  out.div **note_attrs(node) do |div|
47
43
  div.p do |p|
48
- if name
49
- name.children.each { |n| parse(n, p) }
50
- p << termnote_delim
51
- end
44
+ name&.children&.each { |n| parse(n, p) }
45
+ p << " "
52
46
  para_then_remainder(node.first_element_child, node, p, div)
53
47
  end
54
48
  end
@@ -60,12 +54,16 @@ module IsoDoc
60
54
  end
61
55
  end
62
56
 
57
+ def termdomain_parse(node, out)
58
+ node["hidden"] == "true" and return
59
+ node.children.each { |n| parse(n, out) }
60
+ end
61
+
63
62
  def termdef_parse(node, out)
64
- name = node&.at(ns("./name"))&.remove
63
+ name = node.at(ns("./name"))&.remove
65
64
  out.p class: "TermNum", id: node["id"] do |p|
66
65
  name&.children&.each { |n| parse(n, p) }
67
66
  end
68
- set_termdomain("")
69
67
  node.children.each { |n| parse(n, out) }
70
68
  end
71
69
 
@@ -4,10 +4,6 @@ require "pathname"
4
4
  module IsoDoc
5
5
  module Function
6
6
  module ToWordHtml
7
- def set_termdomain(termdomain)
8
- @termdomain = termdomain
9
- end
10
-
11
7
  def note?
12
8
  @note
13
9
  end
@@ -222,7 +218,7 @@ module IsoDoc
222
218
  when "preferred" then term_parse(node, out)
223
219
  when "admitted" then admitted_term_parse(node, out)
224
220
  when "deprecates" then deprecated_term_parse(node, out)
225
- when "domain" then set_termdomain(node.text)
221
+ when "domain" then termdomain_parse(node, out)
226
222
  when "definition" then definition_parse(node, out)
227
223
  when "termsource" then termref_parse(node, out)
228
224
  when "modification" then modification_parse(node, out)
@@ -261,6 +257,8 @@ module IsoDoc
261
257
  when "location" then location_parse(node, out)
262
258
  when "cross-align" then cross_align_parse(node, out)
263
259
  when "columnbreak" then columnbreak_parse(node, out)
260
+ when "attribution" then attribution_parse(node, out)
261
+ when "author" then author_parse(node, out)
264
262
  when "ruby" then ruby_parse(node, out)
265
263
  when "rt" then rt_parse(node, out)
266
264
  when "rb" then rb_parse(node, out)
@@ -24,7 +24,7 @@ module IsoDoc
24
24
  end
25
25
 
26
26
  def insert_tab(out, count)
27
- tab = %w(Hans Hant).include?(@script) ? "&#x3000;" : "&#xa0; "
27
+ tab = %w(Hans Hant Jpan Kore).include?(@script) ? "&#x3000;" : "&#xa0; "
28
28
  [1..count].each { out << tab }
29
29
  end
30
30
 
data/lib/isodoc/init.rb CHANGED
@@ -140,5 +140,26 @@ module IsoDoc
140
140
  def agency?(text)
141
141
  self.class::AGENCIES.include?(text)
142
142
  end
143
+
144
+ # This is highly specific to ISO, but it's not a bad precedent for
145
+ # references anyway; keeping here instead of in IsoDoc::Iso for now
146
+ def docid_l10n(text)
147
+ text.nil? and return text
148
+ @i18n.all_parts and text.gsub!(/All Parts/i, @i18n.all_parts.downcase)
149
+ text.size < 20 and text.gsub!(/ /, "&#xa0;")
150
+ text
151
+ end
152
+
153
+ def docid_prefix(prefix, docid)
154
+ docid = "#{prefix} #{docid}" if prefix && !omit_docid_prefix(prefix) &&
155
+ !/^#{prefix}\b/.match(docid)
156
+ docid_l10n(docid)
157
+ end
158
+
159
+ def omit_docid_prefix(prefix)
160
+ prefix.nil? || prefix.empty? and return true
161
+ %w(ISO IEC IEV ITU W3C BIPM csd metanorma repository metanorma-ordinal)
162
+ .include? prefix
163
+ end
143
164
  end
144
165
  end