isodoc 2.10.0 → 3.0.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 (83) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/isodoc.gemspec +9 -4
  4. data/lib/isodoc/base_style/all.css +96 -0
  5. data/lib/isodoc/base_style/reset.css +96 -0
  6. data/lib/isodoc/base_style/reset.scss +75 -0
  7. data/lib/isodoc/base_style/scripts.html +45 -14
  8. data/lib/isodoc/class_utils.rb +4 -2
  9. data/lib/isodoc/convert.rb +0 -21
  10. data/lib/isodoc/css.rb +2 -4
  11. data/lib/isodoc/function/blocks.rb +37 -52
  12. data/lib/isodoc/function/blocks_example_note.rb +75 -29
  13. data/lib/isodoc/function/cleanup.rb +9 -44
  14. data/lib/isodoc/function/inline.rb +67 -13
  15. data/lib/isodoc/function/lists.rb +20 -14
  16. data/lib/isodoc/function/references.rb +9 -126
  17. data/lib/isodoc/function/reqt.rb +4 -3
  18. data/lib/isodoc/function/section.rb +30 -35
  19. data/lib/isodoc/function/section_titles.rb +22 -11
  20. data/lib/isodoc/function/table.rb +3 -3
  21. data/lib/isodoc/function/terms.rb +49 -26
  22. data/lib/isodoc/function/to_word_html.rb +46 -16
  23. data/lib/isodoc/function/utils.rb +11 -12
  24. data/lib/isodoc/gem_tasks.rb +1 -1
  25. data/lib/isodoc/html_function/footnotes.rb +2 -1
  26. data/lib/isodoc/html_function/html.rb +5 -7
  27. data/lib/isodoc/html_function/postprocess.rb +25 -6
  28. data/lib/isodoc/html_function/postprocess_cover.rb +13 -7
  29. data/lib/isodoc/html_function/postprocess_footnotes.rb +52 -47
  30. data/lib/isodoc/init.rb +31 -0
  31. data/lib/isodoc/metadata.rb +20 -13
  32. data/lib/isodoc/metadata_contributor.rb +5 -10
  33. data/lib/isodoc/metadata_date.rb +1 -1
  34. data/lib/isodoc/presentation_function/autonum.rb +153 -0
  35. data/lib/isodoc/presentation_function/bibdata.rb +4 -5
  36. data/lib/isodoc/presentation_function/block.rb +107 -40
  37. data/lib/isodoc/presentation_function/concepts.rb +184 -19
  38. data/lib/isodoc/presentation_function/docid.rb +78 -0
  39. data/lib/isodoc/presentation_function/erefs.rb +55 -31
  40. data/lib/isodoc/presentation_function/image.rb +64 -19
  41. data/lib/isodoc/presentation_function/index.rb +180 -0
  42. data/lib/isodoc/presentation_function/inline.rb +47 -16
  43. data/lib/isodoc/presentation_function/math.rb +128 -71
  44. data/lib/isodoc/presentation_function/metadata.rb +29 -66
  45. data/lib/isodoc/presentation_function/refs.rb +75 -28
  46. data/lib/isodoc/presentation_function/reqt.rb +7 -4
  47. data/lib/isodoc/presentation_function/section.rb +51 -129
  48. data/lib/isodoc/presentation_function/sourcecode.rb +52 -19
  49. data/lib/isodoc/presentation_function/terms.rb +107 -118
  50. data/lib/isodoc/presentation_function/title.rb +107 -0
  51. data/lib/isodoc/presentation_function/xrefs.rb +37 -17
  52. data/lib/isodoc/presentation_xml_convert.rb +24 -10
  53. data/lib/isodoc/version.rb +1 -1
  54. data/lib/isodoc/word_function/body.rb +9 -37
  55. data/lib/isodoc/word_function/comments.rb +0 -1
  56. data/lib/isodoc/word_function/footnotes.rb +1 -1
  57. data/lib/isodoc/word_function/lists.rb +13 -9
  58. data/lib/isodoc/word_function/postprocess.rb +6 -0
  59. data/lib/isodoc/word_function/postprocess_cover.rb +6 -4
  60. data/lib/isodoc/word_function/postprocess_table.rb +1 -1
  61. data/lib/isodoc/word_function/postprocess_toc.rb +10 -6
  62. data/lib/isodoc/word_function/table.rb +2 -2
  63. data/lib/isodoc/xref/clause_order.rb +41 -0
  64. data/lib/isodoc/xref/xref_anchor.rb +31 -16
  65. data/lib/isodoc/xref/xref_counter.rb +18 -3
  66. data/lib/isodoc/xref/xref_counter_types.rb +14 -0
  67. data/lib/isodoc/xref/xref_gen.rb +61 -37
  68. data/lib/isodoc/xref/xref_gen_seq.rb +148 -81
  69. data/lib/isodoc/xref/xref_sect_gen.rb +84 -88
  70. data/lib/isodoc/xref/xref_util.rb +53 -4
  71. data/lib/isodoc/xref.rb +29 -10
  72. data/lib/isodoc/xslfo_convert.rb +14 -9
  73. data/lib/isodoc-yaml/i18n-ar.yaml +17 -13
  74. data/lib/isodoc-yaml/i18n-de.yaml +17 -13
  75. data/lib/isodoc-yaml/i18n-en.yaml +18 -17
  76. data/lib/isodoc-yaml/i18n-es.yaml +17 -13
  77. data/lib/isodoc-yaml/i18n-fr.yaml +17 -13
  78. data/lib/isodoc-yaml/i18n-ja.yaml +56 -52
  79. data/lib/isodoc-yaml/i18n-ru.yaml +17 -16
  80. data/lib/isodoc-yaml/i18n-zh-Hans.yaml +17 -13
  81. data/lib/nokogiri/xml/node.rb +14 -0
  82. data/lib/relaton/render-isodoc/config.yml +1 -1
  83. metadata +90 -13
@@ -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,10 +25,9 @@ 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
- parse(n, div) unless n.name == "name"
28
+ parse(n, div) unless n.name == "fmt-name"
39
29
  end
40
- figure_name_parse(node, div, node.at(ns("./name")))
30
+ figure_name_parse(node, div, node.at(ns("./fmt-name")))
41
31
  end
42
32
  end
43
33
 
@@ -47,17 +37,17 @@ module IsoDoc
47
37
 
48
38
  def pseudocode_parse(node, out)
49
39
  @in_figure = true
50
- name = node.at(ns("./name"))
40
+ name = node.at(ns("./fmt-name"))
41
+ s = node.at(ns("./fmt-figure")) || node
51
42
  out.div **pseudocode_attrs(node) do |div|
52
- node.children.each { |n| parse(n, div) unless n.name == "name" }
43
+ s.children.each { |n| parse(n, div) unless n.name == "fmt-name" }
53
44
  sourcecode_name_parse(node, div, name)
54
45
  end
55
46
  @in_figure = false
56
47
  end
57
48
 
58
49
  def sourcecode_name_parse(_node, div, name)
59
- return if name.nil?
60
-
50
+ name.nil? and return
61
51
  div.p class: "SourceTitle", style: "text-align:center;" do |p|
62
52
  name.children.each { |n| parse(n, p) }
63
53
  end
@@ -68,11 +58,13 @@ module IsoDoc
68
58
  end
69
59
 
70
60
  def sourcecode_parse(node, out)
71
- name = node.at(ns("./name"))
61
+ name = node.at(ns("./fmt-name"))
62
+ n = node.at(ns("./fmt-sourcecode"))
63
+ s = n || node
72
64
  out.p **sourcecode_attrs(node) do |div|
73
- sourcecode_parse1(node, div)
65
+ sourcecode_parse1(s, div)
74
66
  end
75
- annotation_parse(node, out)
67
+ annotation_parse(s, out)
76
68
  sourcecode_name_parse(node, out, name)
77
69
  end
78
70
 
@@ -82,7 +74,7 @@ module IsoDoc
82
74
  node.at("./ancestor::xmlns:table[@class = 'rouge-line-table']") and
83
75
  @sourcecode = "table"
84
76
  node.children.each do |n|
85
- %w(name dl).include?(n.name) and next
77
+ %w(fmt-name dl).include?(n.name) and next
86
78
  parse(n, div)
87
79
  end
88
80
  @sourcecode = false
@@ -95,20 +87,18 @@ module IsoDoc
95
87
  def annotation_parse(node, out)
96
88
  dl = node.at(ns("./dl")) or return
97
89
  @sourcecode = false
98
- # @annotation = true
99
90
  out.div class: "annotation" do |div|
100
91
  parse(dl, div)
101
- # @annotation = false
102
92
  end
103
93
  end
104
94
 
105
95
  def formula_parse1(node, out)
106
96
  out.div **attr_code(class: "formula") do |div|
107
97
  div.p do |_p|
108
- parse(node.at(ns("./stem")), div)
109
- if lbl = node&.at(ns("./name"))&.text
98
+ parse(node.at(ns("./fmt-stem")), div)
99
+ if lbl = node&.at(ns("./fmt-name"))&.text
110
100
  insert_tab(div, 1)
111
- div << "(#{lbl})"
101
+ div << lbl
112
102
  end
113
103
  end
114
104
  end
@@ -122,8 +112,7 @@ module IsoDoc
122
112
  out.div **formula_attrs(node) do |div|
123
113
  formula_parse1(node, div)
124
114
  node.children.each do |n|
125
- next if %w(stem name).include? n.name
126
-
115
+ %w(stem fmt-name fmt-stem).include? n.name and next
127
116
  parse(n, div)
128
117
  end
129
118
  end
@@ -132,10 +121,8 @@ module IsoDoc
132
121
  def para_class(node)
133
122
  classtype = nil
134
123
  classtype = "MsoCommentText" if in_comment
135
- classtype = "Sourcecode" if @annotation
136
- if node["type"] == "floating-title"
124
+ node["type"] == "floating-title" and
137
125
  classtype = "h#{node['depth']}"
138
- end
139
126
  classtype ||= node["class"]
140
127
  classtype
141
128
  end
@@ -150,23 +137,13 @@ module IsoDoc
150
137
 
151
138
  def para_parse(node, out)
152
139
  out.p **attr_code(para_attrs(node)) do |p|
153
- unless @termdomain.empty?
154
- p << "&lt;#{@termdomain}&gt; "
155
- @termdomain = ""
156
- end
157
140
  node.children.each { |n| parse(n, p) }
158
141
  end
159
142
  end
160
143
 
161
- def quote_attribution(node, out)
162
- author = node.at(ns("./author"))
163
- source = node.at(ns("./source"))
164
- return if author.nil? && source.nil?
165
-
166
- out.p class: "QuoteAttribution" do |p|
167
- p << "&#x2014; #{author.text}" if author
168
- p << ", " if author && source
169
- eref_parse(source, p) if source
144
+ def attribution_parse(node, out)
145
+ out.div class: "QuoteAttribution" do |d|
146
+ node.children.each { |n| parse(n, d) }
170
147
  end
171
148
  end
172
149
 
@@ -174,17 +151,13 @@ module IsoDoc
174
151
  attrs = para_attrs(node)
175
152
  attrs[:class] = "Quote"
176
153
  out.div **attr_code(attrs) do |p|
177
- node.children.each do |n|
178
- parse(n, p) unless %w(author source).include? n.name
179
- end
180
- quote_attribution(node, out)
154
+ node.children.each { |n| parse(n, p) unless n.name == "source" }
181
155
  end
182
156
  end
183
157
 
184
158
  def passthrough_parse(node, out)
185
- return if node["format"] &&
186
- !(node["format"].split(",").include? @format.to_s)
187
-
159
+ node["formats"] &&
160
+ !(node["formats"].split(" ").include? @format.to_s) and return
188
161
  out.passthrough node.text
189
162
  end
190
163
 
@@ -206,6 +179,18 @@ module IsoDoc
206
179
  end
207
180
  end
208
181
 
182
+ def cross_align_parse(node, out)
183
+ out.table do |t|
184
+ t.tbody do |b|
185
+ node.xpath(ns("./align-cell")).each do |c|
186
+ b.td do |td|
187
+ c.children.each { |n| parse(n, td) }
188
+ end
189
+ end
190
+ end
191
+ end
192
+ end
193
+
209
194
  def columnbreak_parse(node, out); end
210
195
  end
211
196
  end
@@ -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
@@ -20,9 +19,9 @@ module IsoDoc
20
19
  # used if we are boxing examples
21
20
  def example_div_parse(node, out)
22
21
  out.div **example_div_attr(node) do |div|
23
- example_label(node, div, node.at(ns("./name")))
22
+ example_label(node, div, node.at(ns("./fmt-name")))
24
23
  node.children.each do |n|
25
- parse(n, div) unless n.name == "name"
24
+ parse(n, div) unless n.name == "fmt-name"
26
25
  end
27
26
  end
28
27
  end
@@ -40,10 +39,12 @@ module IsoDoc
40
39
  out.table **example_table_attr(node) do |t|
41
40
  t.tr do |tr|
42
41
  tr.td **EXAMPLE_TBL_ATTR do |td|
43
- example_label(node, td, node.at(ns("./name")))
42
+ example_label(node, td, node.at(ns("./fmt-name")))
44
43
  end
45
44
  tr.td **EXAMPLE_TD_ATTR do |td|
46
- node.children.each { |n| parse(n, td) unless n.name == "name" }
45
+ node.children.each do |n|
46
+ parse(n, td) unless n.name == "fmt-name"
47
+ end
47
48
  end
48
49
  end
49
50
  end
@@ -53,32 +54,45 @@ module IsoDoc
53
54
  example_div_parse(node, out)
54
55
  end
55
56
 
56
- def note_delim
57
- ""
57
+ def block_body_first_elem(node)
58
+ node.elements.each do |n|
59
+ %w(title fmt-title fmt-xref-label fmt-name name)
60
+ .include?(n.name) and next
61
+ return n
62
+ end
63
+ nil
64
+ end
65
+
66
+ def starts_with_para?(node)
67
+ block_body_first_elem(node)&.name == "p"
68
+ end
69
+
70
+ def note_p_class
71
+ nil
58
72
  end
59
73
 
60
74
  def note_p_parse(node, div)
61
- name = node.at(ns("./name"))&.remove
62
- div.p do |p|
75
+ name = node.at(ns("./fmt-name"))
76
+ para = node.at(ns("./p"))
77
+ div.p **attr_code(class: note_p_class) do |p|
63
78
  name and p.span class: "note_label" do |s|
64
79
  name.children.each { |n| parse(n, s) }
65
- s << note_delim
66
80
  end
67
- insert_tab(p, 1)
68
- node.first_element_child.children.each { |n| parse(n, p) }
81
+ #insert_tab(p, 1) # TODO to Presentation XML
82
+ children_parse(para, p)
69
83
  end
70
- node.element_children[1..-1].each { |n| parse(n, div) }
84
+ para.xpath("./following-sibling::*").each { |n| parse(n, div) }
71
85
  end
72
86
 
73
87
  def note_parse1(node, div)
74
- name = node.at(ns("./name")) and div.p do |p|
75
- p.span class: "note_label" do |s|
76
- name.remove.children.each { |n| parse(n, s) }
77
- s << note_delim
88
+ name = node.at(ns("./fmt-name")) and
89
+ div.p **attr_code(class: note_p_class) do |p|
90
+ p.span class: "note_label" do |s|
91
+ name.remove.children.each { |n| parse(n, s) }
92
+ end
93
+ #insert_tab(p, 1) # TODO to Presentation XML
78
94
  end
79
- insert_tab(p, 1)
80
- end
81
- node.children.each { |n| parse(n, div) }
95
+ children_parse(node, div)
82
96
  end
83
97
 
84
98
  def keep_style(node)
@@ -101,7 +115,7 @@ module IsoDoc
101
115
  def note_parse(node, out)
102
116
  @note = true
103
117
  out.div **note_attrs(node) do |div|
104
- if node&.at(ns("./*[local-name() != 'name'][1]"))&.name == "p"
118
+ if starts_with_para?(node)
105
119
  note_p_parse(node, div)
106
120
  else
107
121
  note_parse1(node, div)
@@ -112,7 +126,7 @@ module IsoDoc
112
126
 
113
127
  def admonition_name_parse(_node, div, name)
114
128
  div.p class: "AdmonitionTitle", style: "text-align:center;" do |p|
115
- name.children.each { |n| parse(n, p) }
129
+ children_parse(name, p)
116
130
  end
117
131
  end
118
132
 
@@ -121,7 +135,7 @@ module IsoDoc
121
135
  end
122
136
 
123
137
  def admonition_name(node, _type)
124
- node&.at(ns("./name"))
138
+ node&.at(ns("./fmt-name"))
125
139
  end
126
140
 
127
141
  def admonition_attrs(node)
@@ -130,12 +144,44 @@ module IsoDoc
130
144
  end
131
145
 
132
146
  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" }
147
+ out.div **admonition_attrs(node) do |div|
148
+ if starts_with_para?(node)
149
+ admonition_p_parse(node, div)
150
+ else
151
+ admonition_parse1(node, div)
152
+ end
153
+ end
154
+ end
155
+
156
+ # code to allow name and first paragraph to be rendered in same block
157
+ def admonition_p_parse(node, div)
158
+ admonition_parse1(node, div)
159
+ end
160
+
161
+ # code to allow name and first paragraph to be rendered in same block
162
+ def admonition_name_in_first_para(node, div)
163
+ name = node.at(ns("./fmt-name"))
164
+ para = node.at(ns("./p"))
165
+ div.p do |p|
166
+ if name = admonition_name(node, node["type"])&.remove
167
+ name.children.each { |n| parse(n, p) }
168
+ admonition_name_para_delim(p) # TODO to Presentation XML
169
+ end
170
+ para.children.each { |n| parse(n, p) }
171
+ end
172
+ para.xpath("./following-sibling::*").each { |n| parse(n, div) }
173
+ end
174
+
175
+ def admonition_name_para_delim(para)
176
+ insert_tab(para, 1)
177
+ end
178
+
179
+ def admonition_parse1(node, div)
180
+ name = admonition_name(node, node["type"])
181
+ if name
182
+ admonition_name_parse(node, div, name)
138
183
  end
184
+ node.children.each { |n| parse(n, div) unless n.name == "fmt-name" }
139
185
  end
140
186
  end
141
187
  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,12 +52,13 @@ module IsoDoc
89
52
  if n.nil?
90
53
  x.name = "p"
91
54
  else
92
- n.children.first.previous = x.remove
55
+ n.add_first_child(x.remove)
93
56
  end
94
57
  end
95
58
  docxml
96
59
  end
97
60
 
61
+ # todo PRESENTATION XML
98
62
  def footnote_cleanup(docxml)
99
63
  docxml.xpath('//a[@class = "FootnoteRef"]/sup')
100
64
  .each_with_index do |x, i|
@@ -157,13 +121,14 @@ module IsoDoc
157
121
  tfoot.xpath(".//td").last
158
122
  end
159
123
 
124
+ TABLENOTE_CSS = "div[@class = 'Note' or @class = 'BlockSource' " \
125
+ "or @class = 'TableFootnote' or @class = 'figdl']".freeze
126
+
160
127
  def table_note_cleanup(docxml)
161
- docxml.xpath("//table[dl or div[@class = 'Note' or @class = 'BlockSource' " \
162
- "or @class = 'TableFootnote']]").each do |t|
128
+ docxml.xpath("//table[dl or #{TABLENOTE_CSS}]").each do |t|
163
129
  tfoot = table_get_or_make_tfoot(t)
164
130
  insert_here = new_fullcolspan_row(t, tfoot)
165
- t.xpath("dl | div[@class = 'Note' or @class = 'BlockSource' or " \
166
- "@class = 'TableFootnote']")
131
+ t.xpath("dl | p[@class = 'ListTitle'] | #{TABLENOTE_CSS}")
167
132
  .each do |d|
168
133
  d.parent = insert_here
169
134
  end
@@ -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
@@ -16,16 +17,24 @@ module IsoDoc
16
17
 
17
18
  def location_parse(node, out); end
18
19
 
20
+ # Presentation XML classes which we need not pass on to HTML or DOC
21
+ SPAN_UNWRAP_CLASSES =
22
+ %w[fmt-caption-label fmt-label-delim fmt-caption-delim fmt-autonum-delim
23
+ fmt-element-name fmt-conn fmt-comma fmt-enum-comma fmt-obligation
24
+ fmt-xref-container fmt-designation-field].freeze
25
+
19
26
  def span_parse(node, out)
20
- if node["style"] || node["class"]
27
+ klass = node["style"] || node["class"]
28
+ if klass && !SPAN_UNWRAP_CLASSES.include?(klass)
21
29
  out.span **attr_code(style: node["style"],
22
30
  class: node["class"]) do |s|
23
- node.children.each { |n| parse(n, s) }
31
+ children_parse(node, s)
24
32
  end
25
- else node.children.each { |n| parse(n, out) }
33
+ else children_parse(node, out)
26
34
  end
27
35
  end
28
36
 
37
+ # todo PRESENTATION XML
29
38
  def callout_parse(node, out)
30
39
  out << " &lt;#{node.text}&gt;"
31
40
  end
@@ -46,9 +55,8 @@ module IsoDoc
46
55
  end
47
56
 
48
57
  def suffix_url(url)
49
- return url if url.nil? || %r{^https?://|^#}.match?(url)
50
- return url unless File.extname(url).empty?
51
-
58
+ url.nil? || %r{^https?://|^#}.match?(url) and return url
59
+ File.extname(url).empty? or return url
52
60
  url.sub(/#{File.extname(url)}$/, ".html")
53
61
  end
54
62
 
@@ -64,6 +72,7 @@ module IsoDoc
64
72
  end
65
73
  end
66
74
 
75
+ # todo PRESENTATION XML
67
76
  def termrefelem_parse(node, out)
68
77
  if node.text.strip.empty?
69
78
  out << "Termbase #{node['base']}, term ID #{node['target']}"
@@ -73,11 +82,12 @@ module IsoDoc
73
82
  end
74
83
 
75
84
  def stem_parse(node, out)
85
+ ret = node.at(ns("./semx[@element = 'stem']")) || node
76
86
  ooml = case node["type"]
77
- when "AsciiMath" then asciimath_parse(node)
78
- when "MathML" then mathml_parse(node)
79
- when "LaTeX" then latexmath_parse(node)
80
- else HTMLEntities.new.encode(node.text)
87
+ when "AsciiMath" then asciimath_parse(ret)
88
+ when "MathML" then mathml_parse(ret)
89
+ when "LaTeX" then latexmath_parse(ret)
90
+ else HTMLEntities.new.encode(ret.text)
81
91
  end
82
92
  out.span class: "stem" do |span|
83
93
  span.parent.add_child ooml
@@ -133,8 +143,7 @@ module IsoDoc
133
143
  end
134
144
 
135
145
  def text_parse(node, out)
136
- return if node.nil? || node.text.nil?
137
-
146
+ node.nil? || node.text.nil? and return
138
147
  text = node.to_s
139
148
  @sourcecode == "pre" and
140
149
  text = text.gsub("\n", "<br/>").gsub("<br/> ", "<br/>&#xa0;")
@@ -179,6 +188,51 @@ module IsoDoc
179
188
  node.children.each { |n| parse(n, e) }
180
189
  end
181
190
  end
191
+
192
+ def author_parse(node, out); end
193
+
194
+ def semx_parse(node, out)
195
+ children_parse(node, out)
196
+ end
197
+
198
+ def children_parse(node, out)
199
+ node.children.each { |n| parse(n, out) }
200
+ end
201
+
202
+ def xref_label_parse(node, out); end
203
+
204
+ def name_parse(node, out); end
205
+ def semx_definition_parse(node, out); end
206
+ def semx_xref_parse(node, out); end
207
+ def semx_eref_parse(node, out); end
208
+ def semx_link_parse(node, out); end
209
+ def semx_origin_parse(node, out); end
210
+ def date_parse(node, out); end
211
+ def semx_stem_parse(node, out); end
212
+
213
+ def floating_title_parse(node, out); end
214
+ def identifier_parse(node, out); end
215
+ def concept_parse(node, out); end
216
+ def erefstack_parse(node, out); end
217
+ def svgmap_parse(node, out); end
218
+ def amend_parse(node, out); end
219
+ def semx_sourcecode_parse(node, out); end
220
+
221
+ def fmt_name_parse(node, out)
222
+ children_parse(node, out)
223
+ end
224
+
225
+ def fmt_identifier_parse(node, out)
226
+ children_parse(node, out)
227
+ end
228
+
229
+ def fmt_concept_parse(node, out)
230
+ children_parse(node, out)
231
+ end
232
+
233
+ def fmt_date_parse(node, out)
234
+ children_parse(node, out)
235
+ end
182
236
  end
183
237
  end
184
238
  end
@@ -2,9 +2,9 @@ module IsoDoc
2
2
  module Function
3
3
  module Lists
4
4
  def list_title_parse(node, out)
5
- name = node.at(ns("./name")) or return
5
+ name = node.at(ns("./fmt-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
 
@@ -13,9 +13,11 @@ module IsoDoc
13
13
  end
14
14
 
15
15
  def ul_parse(node, out)
16
- list_title_parse(node, out)
17
- out.ul **attr_code(ul_attrs(node)) do |ul|
18
- node.children.each { |n| n.name == "name" or parse(n, ul) }
16
+ out.div **attr_code(class: "ul_wrap") do |div|
17
+ list_title_parse(node, div)
18
+ div.ul **attr_code(ul_attrs(node)) do |ul|
19
+ node.children.each { |n| n.name == "fmt-name" or parse(n, ul) }
20
+ end
19
21
  end
20
22
  end
21
23
 
@@ -52,9 +54,11 @@ module IsoDoc
52
54
  end
53
55
 
54
56
  def ol_parse(node, out)
55
- list_title_parse(node, out)
56
- out.ol **attr_code(ol_attrs(node)) do |ol|
57
- node.children.each { |n| n.name == "name" or parse(n, ol) }
57
+ out.div **attr_code(class: "ol_wrap") do |div|
58
+ list_title_parse(node, div)
59
+ div.ol **attr_code(ol_attrs(node)) do |ol|
60
+ node.children.each { |n| n.name == "fmt-name" or parse(n, ol) }
61
+ end
58
62
  end
59
63
  end
60
64
 
@@ -90,17 +94,19 @@ module IsoDoc
90
94
  end
91
95
 
92
96
  def dl_parse(node, out)
93
- list_title_parse(node, out)
94
- out.dl **dl_attrs(node) do |v|
95
- node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
96
- dl_parse1(v, dt, dd)
97
+ out.div **attr_code(class: "figdl") do |div|
98
+ list_title_parse(node, div)
99
+ div.dl **dl_attrs(node) do |v|
100
+ node.elements.select { |n| dt_dd? n }.each_slice(2) do |dt, dd|
101
+ dl_parse1(v, dt, dd)
102
+ end
97
103
  end
104
+ dl_parse_notes(node, div)
98
105
  end
99
- dl_parse_notes(node, out)
100
106
  end
101
107
 
102
108
  def dl_parse_notes(node, out)
103
- node.elements.reject { |n| dt_dd?(n) || n.name == "name" }
109
+ node.elements.reject { |n| dt_dd?(n) || n.name == "fmt-name" }
104
110
  .each { |n| parse(n, out) }
105
111
  end
106
112