isodoc 2.12.1 → 2.12.3

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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +1 -1
  3. data/lib/isodoc/convert.rb +0 -21
  4. data/lib/isodoc/function/blocks.rb +8 -8
  5. data/lib/isodoc/function/blocks_example_note.rb +46 -23
  6. data/lib/isodoc/function/inline.rb +31 -8
  7. data/lib/isodoc/function/lists.rb +4 -4
  8. data/lib/isodoc/function/references.rb +5 -5
  9. data/lib/isodoc/function/reqt.rb +2 -2
  10. data/lib/isodoc/function/section.rb +25 -25
  11. data/lib/isodoc/function/section_titles.rb +15 -12
  12. data/lib/isodoc/function/table.rb +1 -1
  13. data/lib/isodoc/function/terms.rb +17 -14
  14. data/lib/isodoc/function/to_word_html.rb +5 -0
  15. data/lib/isodoc/html_function/footnotes.rb +2 -1
  16. data/lib/isodoc/html_function/html.rb +1 -5
  17. data/lib/isodoc/init.rb +14 -4
  18. data/lib/isodoc/metadata.rb +9 -0
  19. data/lib/isodoc/metadata_contributor.rb +1 -1
  20. data/lib/isodoc/metadata_date.rb +1 -1
  21. data/lib/isodoc/presentation_function/autonum.rb +139 -0
  22. data/lib/isodoc/presentation_function/block.rb +48 -39
  23. data/lib/isodoc/presentation_function/docid.rb +0 -23
  24. data/lib/isodoc/presentation_function/erefs.rb +4 -2
  25. data/lib/isodoc/presentation_function/image.rb +21 -5
  26. data/lib/isodoc/presentation_function/inline.rb +1 -1
  27. data/lib/isodoc/presentation_function/reqt.rb +1 -1
  28. data/lib/isodoc/presentation_function/section.rb +46 -118
  29. data/lib/isodoc/presentation_function/sourcecode.rb +7 -4
  30. data/lib/isodoc/presentation_function/terms.rb +3 -4
  31. data/lib/isodoc/presentation_function/title.rb +107 -0
  32. data/lib/isodoc/presentation_function/xrefs.rb +17 -10
  33. data/lib/isodoc/presentation_xml_convert.rb +2 -1
  34. data/lib/isodoc/version.rb +1 -1
  35. data/lib/isodoc/word_function/body.rb +7 -35
  36. data/lib/isodoc/word_function/footnotes.rb +1 -1
  37. data/lib/isodoc/word_function/lists.rb +12 -10
  38. data/lib/isodoc/word_function/postprocess_cover.rb +0 -2
  39. data/lib/isodoc/word_function/postprocess_table.rb +1 -1
  40. data/lib/isodoc/word_function/postprocess_toc.rb +1 -1
  41. data/lib/isodoc/word_function/table.rb +2 -2
  42. data/lib/isodoc/xref/xref_anchor.rb +31 -16
  43. data/lib/isodoc/xref/xref_counter_types.rb +3 -2
  44. data/lib/isodoc/xref/xref_gen.rb +57 -33
  45. data/lib/isodoc/xref/xref_gen_seq.rb +145 -56
  46. data/lib/isodoc/xref/xref_sect_gen.rb +60 -28
  47. data/lib/isodoc/xref/xref_util.rb +43 -1
  48. data/lib/isodoc/xref.rb +3 -0
  49. data/lib/isodoc-yaml/i18n-ar.yaml +9 -9
  50. data/lib/isodoc-yaml/i18n-de.yaml +9 -9
  51. data/lib/isodoc-yaml/i18n-en.yaml +9 -9
  52. data/lib/isodoc-yaml/i18n-es.yaml +9 -9
  53. data/lib/isodoc-yaml/i18n-fr.yaml +9 -9
  54. data/lib/isodoc-yaml/i18n-ja.yaml +10 -10
  55. data/lib/isodoc-yaml/i18n-ru.yaml +9 -9
  56. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +9 -9
  57. data/lib/nokogiri/xml/node.rb +1 -0
  58. metadata +6 -4
@@ -1,26 +1,12 @@
1
1
  require_relative "refs"
2
+ require_relative "title"
2
3
 
3
4
  module IsoDoc
4
5
  class PresentationXMLConvert < ::IsoDoc::Convert
5
- def middle_title(docxml)
6
- s = docxml.at(ns("//sections")) or return
7
- t = @meta.get[:doctitle]
8
- t.nil? || t.empty? and return
9
- s.add_first_child "<p class='zzSTDTitle1'>#{t}</p>"
10
- end
11
-
12
- def missing_title(docxml)
13
- docxml.xpath(ns("//definitions[not(./title)]")).each do |d|
14
- # should only be happening for subclauses
15
- d.add_first_child "<title>#{@i18n.symbols}</title>"
16
- end
17
- docxml.xpath(ns("//foreword[not(./title)]")).each do |d|
18
- d.add_first_child "<title>#{@i18n.foreword}</title>"
19
- end
20
- end
21
-
22
6
  def clause(docxml)
23
- docxml.xpath(ns("//clause | //terms | //definitions | //references"))
7
+ docxml.xpath(ns("//clause | //terms | //definitions | //references | " \
8
+ "//introduction | //foreword | //preface/abstract | " \
9
+ "//acknowledgements | //colophon | //indexsect "))
24
10
  .each do |f|
25
11
  f.parent.name == "annex" &&
26
12
  @xrefs.klass.single_term_clause?(f.parent) and next
@@ -34,32 +20,23 @@ module IsoDoc
34
20
  elem.at("./ancestor::*[@unnumbered = 'true']")
35
21
  end
36
22
 
23
+ def clausedelim
24
+ ret = super
25
+ ret && !ret.empty? or return ret
26
+ "<span class='fmt-autonum-delim'>#{ret}</span>"
27
+ end
28
+
37
29
  def clause1(elem)
38
30
  level = @xrefs.anchor(elem["id"], :level, false) ||
39
31
  (elem.ancestors("clause, annex").size + 1)
40
- t = elem.at(ns("./title")) and t["depth"] = level
41
- unnumbered_clause?(elem) and return
42
- lbl = @xrefs.anchor(elem["id"], :label,
43
- elem.parent.name != "sections") or return
44
- prefix_name(elem, "<tab/>", "#{lbl}#{clausedelim}", "title")
45
- end
46
-
47
- def floattitle(docxml)
48
- p = "//clause | //annex | //appendix | //introduction | //foreword | " \
49
- "//preface/abstract | //acknowledgements | //terms | " \
50
- "//definitions | //references | //colophon | //indexsect"
51
- docxml.xpath(ns(p)).each { |f| floattitle1(f) }
52
- # top-level
53
- docxml.xpath(ns("//sections | //preface | //colophon"))
54
- .each { |f| floattitle1(f) }
55
- end
56
-
57
- # TODO not currently doing anything with the @depth attribute of floating-title
58
- def floattitle1(elem)
59
- elem.xpath(ns(".//floating-title")).each do |p|
60
- p.name = "p"
61
- p["type"] = "floating-title"
32
+ lbl = @xrefs.anchor(elem["id"], :label, elem.parent.name != "sections")
33
+ if unnumbered_clause?(elem) || !lbl
34
+ prefix_name(elem, {}, nil, "title")
35
+ else
36
+ prefix_name(elem, { caption: "<tab/>" }, "#{lbl}#{clausedelim}",
37
+ "title")
62
38
  end
39
+ t = elem.at(ns("./fmt-title")) and t["depth"] = level
63
40
  end
64
41
 
65
42
  def annex(docxml)
@@ -73,10 +50,18 @@ module IsoDoc
73
50
 
74
51
  def annex1(elem)
75
52
  lbl = @xrefs.anchor(elem["id"], :label)
53
+ # TODO: do not alter title, alter semx/@element = title
76
54
  t = elem.at(ns("./title")) and
77
55
  t.children = "<strong>#{to_xml(t.children)}</strong>"
78
- unnumbered_clause?(elem) and return
79
- prefix_name(elem, "<br/><br/>", lbl, "title")
56
+ if unnumbered_clause?(elem)
57
+ prefix_name(elem, {}, nil, "title")
58
+ else
59
+ prefix_name(elem, { caption: annex_delim(elem) }, lbl, "title")
60
+ end
61
+ end
62
+
63
+ def annex_delim(_elem)
64
+ "<br/><br/>"
80
65
  end
81
66
 
82
67
  def single_term_clause_retitle(elem)
@@ -91,7 +76,7 @@ module IsoDoc
91
76
  t = elem.at(ns("./terms | ./definitions | ./references"))
92
77
  t.xpath(ns(".//clause | .//terms | .//definitions | .//references"))
93
78
  .each do |c|
94
- tit = c.at(ns("./title")) or return
79
+ tit = c.at(ns("./fmt-title")) or next
95
80
  tit["depth"] = tit["depth"].to_i - 1 unless tit["depth"] == "1"
96
81
  end
97
82
  end
@@ -100,8 +85,13 @@ module IsoDoc
100
85
  docxml.xpath(ns("//index | //index-xref | //indexsect")).each(&:remove)
101
86
  end
102
87
 
88
+ def skip_display_order?(node)
89
+ node.name == "floating-title"
90
+ end
91
+
103
92
  def display_order_at(docxml, xpath, idx)
104
93
  c = docxml.at(ns(xpath)) or return idx
94
+ skip_display_order?(c) and return idx
105
95
  idx += 1
106
96
  idx = preceding_floating_titles(c, idx)
107
97
  c["displayorder"] = idx
@@ -110,6 +100,7 @@ module IsoDoc
110
100
 
111
101
  def display_order_xpath(docxml, xpath, idx)
112
102
  docxml.xpath(ns(xpath)).each do |c|
103
+ skip_display_order?(c) and next
113
104
  idx += 1
114
105
  idx = preceding_floating_titles(c, idx)
115
106
  c["displayorder"] = idx
@@ -117,19 +108,6 @@ module IsoDoc
117
108
  idx
118
109
  end
119
110
 
120
- def preceding_floating_titles(node, idx)
121
- out = node.xpath("./preceding-sibling::*")
122
- .reverse.each_with_object([]) do |p, m|
123
- %w(note admonition p).include?(p.name) or break m
124
- m << p
125
- end
126
- out.reject { |c| c["displayorder"] }.reverse_each do |c|
127
- c["displayorder"] = idx
128
- idx += 1
129
- end
130
- idx
131
- end
132
-
133
111
  def display_order(docxml)
134
112
  i = 0
135
113
  d = @xrefs.clause_order(docxml)
@@ -143,46 +121,26 @@ module IsoDoc
143
121
  end
144
122
  end
145
123
 
146
- def clausetitle(docxml)
147
- cjk_extended_title(docxml)
148
- end
149
-
150
- def cjk_search
151
- lang = %w(zh ja ko).map { |x| "@language = '#{x}'" }.join(" or ")
152
- %(Hans Hant Jpan Hang Kore).include?(@script) and
153
- lang += " or not(@language)"
154
- lang
155
- end
156
-
157
- def cjk_extended_title(docxml)
158
- l = cjk_search
159
- docxml.xpath(ns("//bibdata/title[#{l}] | //floating-title[#{l}] | " \
160
- "//title[@depth = '1' or not(@depth)][#{l}]")).each do |t|
161
- t.text.size < 4 or next
162
- t.elements.empty? or next # can't be bothered
163
- t.children = @i18n.cjk_extend(t.text)
164
- end
165
- end
166
-
167
124
  def preface_rearrange(doc)
168
- preface_move(doc.at(ns("//preface/abstract")),
125
+ preface_move(doc.xpath(ns("//preface/abstract")),
169
126
  %w(foreword introduction clause acknowledgements), doc)
170
- preface_move(doc.at(ns("//preface/foreword")),
127
+ preface_move(doc.xpath(ns("//preface/foreword")),
171
128
  %w(introduction clause acknowledgements), doc)
172
- preface_move(doc.at(ns("//preface/introduction")),
129
+ preface_move(doc.xpath(ns("//preface/introduction")),
173
130
  %w(clause acknowledgements), doc)
174
- preface_move(doc.at(ns("//preface/acknowledgements")),
131
+ preface_move(doc.xpath(ns("//preface/acknowledgements")),
175
132
  %w(), doc)
176
133
  end
177
134
 
178
- def preface_move(clause, after, _doc)
179
- clause or return
180
- preface = clause.parent
135
+ def preface_move(clauses, after, _doc)
136
+ clauses.empty? and return
137
+ preface = clauses.first.parent
138
+ clauses.each do |clause|
181
139
  float = preceding_floats(clause)
182
- prev = nil
183
140
  xpath = after.map { |n| "./self::xmlns:#{n}" }.join(" | ")
184
141
  xpath.empty? and xpath = "./self::*[not(following-sibling::*)]"
185
- preface_move1(clause, preface, float, prev, xpath)
142
+ preface_move1(clause, preface, float, nil, xpath)
143
+ end
186
144
  end
187
145
 
188
146
  def preface_move1(clause, preface, float, prev, xpath)
@@ -192,47 +150,17 @@ module IsoDoc
192
150
  x.at(xpath) or next
193
151
  clause == prev and break
194
152
  prev ||= preface.children.first
195
- float << clause
153
+ prev.next = clause
196
154
  float.each { |n| prev.next = n }
197
155
  break
198
156
  end
199
157
  end
200
158
 
201
- def preceding_floats(clause)
202
- ret = []
203
- p = clause
204
- while prev = p.previous_element
205
- if prev.name == "floating-title"
206
- ret << prev
207
- p = prev
208
- else break end
209
- end
210
- ret
211
- end
212
-
213
159
  def rearrange_clauses(docxml)
214
160
  preface_rearrange(docxml) # feeds toc_title
215
161
  toc_title(docxml)
216
162
  end
217
163
 
218
- def toc_title(docxml)
219
- docxml.at(ns("//preface/clause[@type = 'toc']")) and return
220
- ins = toc_title_insert_pt(docxml) or return
221
- id = UUIDTools::UUID.random_create.to_s
222
- ins.previous = <<~CLAUSE
223
- <clause type = 'toc' id='_#{id}'><title depth='1'>#{@i18n.table_of_contents}</title></clause>
224
- CLAUSE
225
- end
226
-
227
- def toc_title_insert_pt(docxml)
228
- ins = docxml.at(ns("//preface")) ||
229
- docxml.at(ns("//sections | //annex | //bibliography"))
230
- &.before("<preface> </preface>")
231
- &.previous_element or return nil
232
- ins.children.empty? and ins << " "
233
- ins.children.first
234
- end
235
-
236
164
  def toc(docxml)
237
165
  toc_refs(docxml)
238
166
  end
@@ -240,7 +168,7 @@ module IsoDoc
240
168
  def toc_refs(docxml)
241
169
  docxml.xpath(ns("//toc//xref[text()]")).each do |x|
242
170
  lbl = @xrefs.anchor(x["target"], :label) or next
243
- x.add_first_child "#{lbl}<tab/>"
171
+ x.add_first_child "#{lbl}<span class='fmt-caption-delim'><tab/></span>"
244
172
  end
245
173
  end
246
174
  end
@@ -150,10 +150,13 @@ module IsoDoc
150
150
  end
151
151
 
152
152
  def source_label(elem)
153
- labelled_ancestor(elem) and return
154
- lbl = @xrefs.anchor(elem["id"], :label, false) or return
155
- prefix_name(elem, block_delim,
156
- l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
153
+ if !labelled_ancestor(elem) && # do not number if labelled_ancestor
154
+ lbl = @xrefs.anchor(elem["id"], :label, false)
155
+ #a = autonum(elem["id"], lbl)
156
+ #s = "<span class='fmt-element-name'>#{lower2cap @i18n.figure}</span> #{a}"
157
+ s = labelled_autonum(lower2cap(@i18n.figure), elem["id"], lbl)&.strip
158
+ end
159
+ prefix_name(elem, { caption: block_delim }, s, "name")
157
160
  end
158
161
  end
159
162
  end
@@ -115,12 +115,11 @@ module IsoDoc
115
115
 
116
116
  def termnote1(elem)
117
117
  lbl = termnote_label(elem)
118
- prefix_name(elem, "", lower2cap(lbl), "name")
118
+ prefix_name(elem, { label: termnote_delim(elem) }, lower2cap(lbl), "name")
119
119
  end
120
120
 
121
121
  def termnote_label(elem)
122
- lbl = @xrefs.anchor(elem["id"], :label) || "???"
123
- l10n "#{lbl}#{termnote_delim(elem)}"
122
+ @xrefs.anchor(elem["id"], :label) || "???"
124
123
  end
125
124
 
126
125
  def termdefinition(docxml)
@@ -200,7 +199,7 @@ module IsoDoc
200
199
 
201
200
  def term1(elem)
202
201
  lbl = @xrefs.anchor(elem["id"], :label) or return
203
- prefix_name(elem, "", "#{lbl}#{clausedelim}", "name")
202
+ prefix_name(elem, {}, "#{lbl}#{clausedelim}", "name")
204
203
  end
205
204
  end
206
205
  end
@@ -0,0 +1,107 @@
1
+ require_relative "refs"
2
+
3
+ module IsoDoc
4
+ class PresentationXMLConvert < ::IsoDoc::Convert
5
+ def middle_title(docxml)
6
+ s = docxml.at(ns("//sections")) or return
7
+ t = @meta.get[:doctitle]
8
+ t.nil? || t.empty? and return
9
+ s.add_first_child "<p class='zzSTDTitle1'>#{t}</p>"
10
+ end
11
+
12
+ def missing_title(docxml)
13
+ docxml.xpath(ns("//definitions[not(./title)]")).each do |d|
14
+ # should only be happening for subclauses
15
+ d.add_first_child "<title>#{@i18n.symbols}</title>"
16
+ end
17
+ docxml.xpath(ns("//foreword[not(./title)]")).each do |d|
18
+ d.add_first_child "<title>#{@i18n.foreword}</title>"
19
+ end
20
+ end
21
+
22
+ def floattitle(docxml)
23
+ docxml.xpath(ns(".//floating-title")).each { |f| floattitle1(f) }
24
+ end
25
+
26
+ # TODO not currently doing anything with the @depth attribute of floating-title
27
+ def floattitle1(elem)
28
+ elem["id"] ||= "_#{UUIDTools::UUID.random_create}"
29
+ p = elem.dup
30
+ p.children = "<semx element='floating-title' source='#{elem['id']}'>" \
31
+ "#{to_xml(p.children)}</semx>"
32
+ elem.next = p
33
+ p.name = "p"
34
+ p["type"] = "floating-title"
35
+ transfer_id(elem, p)
36
+ end
37
+
38
+ def preceding_floating_titles(node, idx)
39
+ out = node.xpath("./preceding-sibling::*")
40
+ .reverse.each_with_object([]) do |p, m|
41
+ %w(note admonition p floating-title).include?(p.name) or break m
42
+ m << p
43
+ end
44
+ #require 'debug'; out.empty? or binding.b
45
+ out.reject { |c| c["displayorder"] }.reverse_each do |c|
46
+ skip_display_order?(c) and next
47
+ c["displayorder"] = idx
48
+ idx += 1
49
+ end
50
+ idx
51
+ end
52
+
53
+ def clausetitle(docxml)
54
+ cjk_extended_title(docxml)
55
+ end
56
+
57
+ def cjk_search
58
+ lang = %w(zh ja ko).map { |x| "@language = '#{x}'" }.join(" or ")
59
+ %(Hans Hant Jpan Hang Kore).include?(@script) and
60
+ lang += " or not(@language)"
61
+ lang
62
+ end
63
+
64
+ def cjk_extended_title(doc)
65
+ l = cjk_search
66
+ doc.xpath(ns("//bibdata/title[#{l}] | //floating-title[#{l}] | " \
67
+ "//fmt-title[@depth = '1' or not(@depth)][#{l}]"))
68
+ .each do |t|
69
+ t.text.size < 4 or next
70
+ t.traverse do |n|
71
+ n.text? or next
72
+ n.replace(@i18n.cjk_extend(n.text))
73
+ end
74
+ end
75
+ end
76
+
77
+ def preceding_floats(clause)
78
+ ret = []
79
+ p = clause
80
+ while prev = p.previous_element
81
+ if prev.name == "floating-title"
82
+ ret << prev
83
+ p = prev
84
+ else break end
85
+ end
86
+ ret
87
+ end
88
+
89
+ def toc_title(docxml)
90
+ docxml.at(ns("//preface/clause[@type = 'toc']")) and return
91
+ ins = toc_title_insert_pt(docxml) or return
92
+ id = UUIDTools::UUID.random_create.to_s
93
+ ins.previous = <<~CLAUSE
94
+ <clause type = 'toc' id='_#{id}'><fmt-title depth='1'>#{@i18n.table_of_contents}</fmt-title></clause>
95
+ CLAUSE
96
+ end
97
+
98
+ def toc_title_insert_pt(docxml)
99
+ ins = docxml.at(ns("//preface")) ||
100
+ docxml.at(ns("//sections | //annex | //bibliography"))
101
+ &.before("<preface> </preface>")
102
+ &.previous_element or return nil
103
+ ins.children.empty? and ins << " "
104
+ ins.children.first
105
+ end
106
+ end
107
+ end
@@ -7,13 +7,14 @@ module IsoDoc
7
7
  prefix_container(container_container,
8
8
  anchor_xref(node, container, container: true),
9
9
  node, target)
10
- l10n(@i18n.nested_xref.sub("%1", container_label)
11
- .sub("%2", linkend))
10
+ l10n(connectives_spans(@i18n.nested_xref
11
+ .sub("%1", "<span class='fmt-xref-container'>#{container_label}</span>")
12
+ .sub("%2", linkend)))
12
13
  end
13
14
 
14
15
  def anchor_value(id)
15
- @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :value) ||
16
- @xrefs.anchor(id, :label) || @xrefs.anchor(id, :xref)
16
+ @xrefs.anchor(id, :bare_xref) || @xrefs.anchor(id, :label) ||
17
+ @xrefs.anchor(id, :value) || @xrefs.anchor(id, :xref)
17
18
  end
18
19
 
19
20
  def anchor_linkend(node, linkend)
@@ -55,14 +56,15 @@ module IsoDoc
55
56
 
56
57
  def anchor_xref_short(node, target, container)
57
58
  if (l = node["label"]) && !container
58
- @i18n.l10n("#{l} #{anchor_value(target)}")
59
+ v = anchor_value(target)
60
+ @i18n.l10n(%[<span class="fmt-element-name">#{l}</span> #{v}])
59
61
  else @xrefs.anchor(target, :xref)
60
62
  end
61
63
  end
62
64
 
63
65
  def anchor_xref_full(num, title)
64
66
  (!title.nil? && !title.empty?) or return nil
65
- l10n("#{num}, #{title}")
67
+ l10n("#{num}<span class='fmt-comma'>,</span> #{title}")
66
68
  end
67
69
 
68
70
  def prefix_container?(container, node)
@@ -133,9 +135,13 @@ module IsoDoc
133
135
  def combine_conn(list)
134
136
  list.size == 1 and list.first[:label]
135
137
  if list[1..].all? { |l| l[:conn] == "and" }
136
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "and")
138
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
139
+ loc2xref(l)
140
+ end, "and"))
137
141
  elsif list[1..].all? { |l| l[:conn] == "or" }
138
- @i18n.boolean_conj(list.map { |l| loc2xref(l) }, "or")
142
+ connectives_spans(@i18n.boolean_conj(list.map do |l|
143
+ loc2xref(l)
144
+ end, "or"))
139
145
  else
140
146
  ret = loc2xref(list[0])
141
147
  list[1..].each { |l| ret = i18n_chain_boolean(ret, l) }
@@ -144,8 +150,9 @@ module IsoDoc
144
150
  end
145
151
 
146
152
  def i18n_chain_boolean(value, entry)
147
- @i18n.send("chain_#{entry[:conn]}").sub("%1", value)
148
- .sub("%2", loc2xref(entry))
153
+ connectives_spans(@i18n.send("chain_#{entry[:conn]}")
154
+ .sub("%1", value)
155
+ .sub("%2", loc2xref(entry)))
149
156
  end
150
157
 
151
158
  def can_conflate_xref_rendering?(locs)
@@ -62,9 +62,9 @@ module IsoDoc
62
62
  annex docxml
63
63
  clause docxml # feeds clausetitle
64
64
  term docxml
65
- index docxml
66
65
  clausetitle docxml # feeds floattitle
67
66
  floattitle docxml # feeds rearrange_clauses
67
+ index docxml # fed by strip_duplicate_ids
68
68
  toc docxml
69
69
  display_order docxml
70
70
  end
@@ -79,6 +79,7 @@ module IsoDoc
79
79
  note docxml
80
80
  admonition docxml
81
81
  source docxml
82
+ ul docxml
82
83
  ol docxml
83
84
  dl docxml
84
85
  quote docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "2.12.1".freeze
2
+ VERSION = "2.12.3".freeze
3
3
  end
@@ -102,40 +102,12 @@ module IsoDoc
102
102
  end
103
103
  end
104
104
 
105
- def note_p_parse(node, div)
106
- name = node.at(ns("./name"))&.remove
107
- div.p class: "Note" do |p|
108
- p.span class: "note_label" do |s|
109
- name&.children&.each { |n| parse(n, s) }
110
- end
111
- insert_tab(p, 1)
112
- node.first_element_child.children.each { |n| parse(n, p) }
113
- end
114
- node.element_children[1..].each { |n| parse(n, div) }
105
+ def note_p_class
106
+ "Note"
115
107
  end
116
108
 
117
- def note_parse1(node, div)
118
- name = node.at(ns("./name"))&.remove
119
- div.p class: "Note" do |p|
120
- p.span class: "note_label" do |s|
121
- name&.children&.each { |n| parse(n, s) }
122
- end
123
- insert_tab(p, 1)
124
- end
125
- node.children.each { |n| parse(n, div) }
126
- end
127
-
128
- def termnote_parse(node, out)
129
- name = node&.at(ns("./name"))&.remove
130
- out.div **note_attrs(node) do |div|
131
- div.p class: "Note" do |p|
132
- if name
133
- name.children.each { |n| parse(n, p) }
134
- p << " "
135
- end
136
- para_then_remainder(node.first_element_child, node, p, div)
137
- end
138
- end
109
+ def termnote_p_class
110
+ "Note"
139
111
  end
140
112
 
141
113
  def para_attrs(node)
@@ -164,7 +136,7 @@ module IsoDoc
164
136
  div.p do |_p|
165
137
  parse(node.at(ns("./stem")), div)
166
138
  insert_tab(div, 1)
167
- if lbl = node&.at(ns("./name"))&.text
139
+ if lbl = node&.at(ns("./fmt-name"))&.text
168
140
  div << lbl
169
141
  end
170
142
  end
@@ -185,10 +157,10 @@ module IsoDoc
185
157
  page_break(out)
186
158
  out.div **attr_code(preface_attrs(clause)) do |div|
187
159
  div.p class: "zzContents" do |p|
188
- clause.at(ns("./title"))&.children&.each { |c| parse(c, p) }
160
+ clause.at(ns("./fmt-title"))&.children&.each { |c| parse(c, p) }
189
161
  end
190
162
  clause.elements.each do |e|
191
- parse(e, div) unless e.name == "title"
163
+ parse(e, div) unless e.name == "fmt-title"
192
164
  end
193
165
  end
194
166
  end
@@ -83,7 +83,7 @@ module IsoDoc
83
83
 
84
84
  def footnote_parse(node, out)
85
85
  return table_footnote_parse(node, out) if (@in_table || @in_figure) &&
86
- !node.ancestors.map(&:name).include?("name")
86
+ !node.ancestors.map(&:name).include?("fmt-name")
87
87
 
88
88
  fn = node["reference"] || UUIDTools::UUID.random_create.to_s
89
89
  return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
@@ -25,13 +25,13 @@ module IsoDoc
25
25
 
26
26
  def dl_parse_nontable(node, out)
27
27
  out.div **attr_code(class: "figdl") do |div|
28
- node["id"] and bookmark_parse(node, div)
29
- list_title_parse(node, div)
30
- node.elements.select { |n| dt_dd?(n) }
31
- .each_slice(2) do |dt, dd|
32
- dl_parse_nontable1(div, dt, dd)
33
- end
34
- dl_parse_notes(node, div)
28
+ node["id"] and bookmark_parse(node, div)
29
+ list_title_parse(node, div)
30
+ node.elements.select { |n| dt_dd?(n) }
31
+ .each_slice(2) do |dt, dd|
32
+ dl_parse_nontable1(div, dt, dd)
33
+ end
34
+ dl_parse_notes(node, div)
35
35
  end
36
36
  end
37
37
 
@@ -58,13 +58,13 @@ module IsoDoc
58
58
 
59
59
  def ddef_other_paras(out, ddef)
60
60
  ddef.elements&.first&.name == "p" or return
61
- ddef.children[1..-1].each { |n| parse(n, out) }
61
+ ddef.children[1..].each { |n| parse(n, out) }
62
62
  end
63
63
 
64
64
  def dl_parse_table(node, out)
65
65
  list_title_parse(node, out)
66
66
  out.table **attr_code(id: node["id"],
67
- class: (node["class"] || "dl")) do |v|
67
+ class: node["class"] || "dl") do |v|
68
68
  node.elements.select { |n| dt_dd?(n) }
69
69
  .each_slice(2) do |dt, dd|
70
70
  dl_parse_table1(v, dt, dd)
@@ -85,7 +85,9 @@ module IsoDoc
85
85
  end
86
86
 
87
87
  def dl_parse_table_notes(node, out)
88
- remainder = node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
88
+ remainder = node.elements.reject do |n|
89
+ dt_dd?(n) || n.name == "fmt-name"
90
+ end
89
91
  remainder.empty? and return
90
92
  out.tr do |tr|
91
93
  tr.td colspan: 2 do |td|
@@ -22,7 +22,6 @@ module IsoDoc
22
22
  cover = File.read(@wordcoverpage, encoding: "UTF-8")
23
23
  cover = populate_template(cover, :word)
24
24
  coverxml = to_word_xhtml_fragment(cover)
25
- #ins.children.first.previous = coverxml.to_xml(encoding: "US-ASCII")
26
25
  ins.add_first_child coverxml.to_xml(encoding: "US-ASCII")
27
26
  end
28
27
 
@@ -32,7 +31,6 @@ module IsoDoc
32
31
  docxml, level)
33
32
  intro = populate_template(intro, :word)
34
33
  introxml = to_word_xhtml_fragment(intro)
35
- #ins.children.first.previous = introxml.to_xml(encoding: "US-ASCII")
36
34
  ins.add_first_child introxml.to_xml(encoding: "US-ASCII")
37
35
  end
38
36
 
@@ -44,7 +44,7 @@ module IsoDoc
44
44
 
45
45
  def word_nested_tables(docxml)
46
46
  docxml.xpath("//table").each do |t|
47
- t.xpath(".//table").reverse.each do |tt|
47
+ t.xpath(".//table").reverse_each do |tt|
48
48
  t.next = tt.remove
49
49
  end
50
50
  end
@@ -169,7 +169,7 @@ module IsoDoc
169
169
  def recommmendation_sort_key(header)
170
170
  m = /^([^0-9]+) (\d+)/.match(header) || /^([^:]+)/.match(header)
171
171
  m ||= [header, nil]
172
- ret = "#{recommmendation_sort_key1(m[1])}::"
172
+ ret = "#{recommmendation_sort_key1(m[1]&.strip)}::"
173
173
  m[2] and ret += ("%04d" % m[2].to_i).to_s
174
174
  ret
175
175
  end