isodoc 1.7.3 → 1.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +7 -4
  3. data/lib/isodoc/class_utils.rb +2 -2
  4. data/lib/isodoc/convert.rb +2 -0
  5. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  6. data/lib/isodoc/function/cleanup.rb +181 -175
  7. data/lib/isodoc/function/inline.rb +110 -108
  8. data/lib/isodoc/function/inline_simple.rb +55 -55
  9. data/lib/isodoc/function/lists.rb +75 -71
  10. data/lib/isodoc/function/references.rb +165 -160
  11. data/lib/isodoc/function/section.rb +140 -190
  12. data/lib/isodoc/function/section_titles.rb +82 -0
  13. data/lib/isodoc/function/table.rb +90 -87
  14. data/lib/isodoc/function/terms.rb +58 -56
  15. data/lib/isodoc/function/to_word_html.rb +3 -1
  16. data/lib/isodoc/function/utils.rb +34 -14
  17. data/lib/isodoc/html_function/comments.rb +107 -111
  18. data/lib/isodoc/html_function/footnotes.rb +68 -67
  19. data/lib/isodoc/html_function/html.rb +113 -103
  20. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  21. data/lib/isodoc/presentation_function/block.rb +73 -78
  22. data/lib/isodoc/presentation_function/concept.rb +68 -0
  23. data/lib/isodoc/presentation_function/image.rb +112 -0
  24. data/lib/isodoc/presentation_function/inline.rb +6 -39
  25. data/lib/isodoc/presentation_function/math.rb +9 -0
  26. data/lib/isodoc/presentation_function/section.rb +12 -1
  27. data/lib/isodoc/presentation_xml_convert.rb +3 -0
  28. data/lib/isodoc/version.rb +1 -1
  29. data/lib/isodoc/word_function/body.rb +176 -174
  30. data/lib/isodoc/word_function/comments.rb +117 -112
  31. data/lib/isodoc/word_function/footnotes.rb +88 -86
  32. data/lib/isodoc/word_function/inline.rb +42 -67
  33. data/lib/isodoc/word_function/postprocess_cover.rb +121 -110
  34. data/lib/isodoc/xref/xref_gen.rb +153 -150
  35. data/lib/isodoc/xslfo_convert.rb +2 -2
  36. data/lib/isodoc.rb +1 -1
  37. data/spec/assets/odf.svg +1 -4
  38. data/spec/isodoc/blocks_spec.rb +187 -32
  39. data/spec/isodoc/inline_spec.rb +300 -116
  40. data/spec/isodoc/postproc_spec.rb +38 -0
  41. data/spec/isodoc/presentation_xml_spec.rb +144 -0
  42. data/spec/isodoc/section_spec.rb +764 -0
  43. data/spec/isodoc/terms_spec.rb +116 -0
  44. metadata +63 -18
@@ -41,6 +41,7 @@ module IsoDoc
41
41
  def convert
42
42
  docxml.xpath("//m:math", MATHML).each do |elem|
43
43
  next if nothing_to_style(elem)
44
+
44
45
  mathml1(elem)
45
46
  end
46
47
  docxml
@@ -49,7 +50,8 @@ module IsoDoc
49
50
  private
50
51
 
51
52
  def nothing_to_style(elem)
52
- !elem.at("./*[@mathvariant][not(@mathvariant = 'normal')][not(@mathvariant = 'italic')]")
53
+ !elem.at("./*[@mathvariant][not(@mathvariant = 'normal')]"\
54
+ "[not(@mathvariant = 'italic')]")
53
55
  end
54
56
 
55
57
  def mathml1(base_elem)
@@ -58,7 +60,7 @@ module IsoDoc
58
60
  .merge(MATHVARIANT_TO_PLANE_MAPPINGS)
59
61
  .each_pair do |mathvariant_list, plain_font|
60
62
  base_elem.xpath(mathvariant_xpath(mathvariant_list)).each do |elem|
61
- toPlane(elem, plain_font)
63
+ to_plane(elem, plain_font)
62
64
  end
63
65
  end
64
66
  end
@@ -69,7 +71,7 @@ module IsoDoc
69
71
  .join
70
72
  end
71
73
 
72
- def toPlane(elem, font)
74
+ def to_plane(elem, font)
73
75
  elem.traverse do |n|
74
76
  next unless n.text?
75
77
 
@@ -1,55 +1,24 @@
1
- require "base64"
1
+ require_relative "./image"
2
2
 
3
3
  module IsoDoc
4
4
  class PresentationXMLConvert < ::IsoDoc::Convert
5
- def lower2cap(s)
6
- return s if /^[[:upper:]][[:upper:]]/.match?(s)
5
+ def lower2cap(text)
6
+ return text if /^[[:upper:]][[:upper:]]/.match?(text)
7
7
 
8
- s.capitalize
8
+ text.capitalize
9
9
  end
10
10
 
11
- def figure(docxml)
12
- docxml.xpath(ns("//image")).each { |f| svg_extract(f) }
13
- docxml.xpath(ns("//figure")).each { |f| figure1(f) }
14
- docxml.xpath(ns("//svgmap")).each do |s|
15
- if f = s.at(ns("./figure")) then s.replace(f)
16
- else
17
- s.remove
18
- end
19
- end
20
- end
21
-
22
- def svg_extract(elem)
23
- return unless %r{^data:image/svg\+xml;base64,}.match?(elem["src"])
24
-
25
- svg = Base64.strict_decode64(elem["src"]
26
- .sub(%r{^data:image/svg\+xml;base64,}, ""))
27
- x = Nokogiri::XML.fragment(svg.sub(/<\?xml[^>]*>/, "")) do |config|
28
- config.huge
29
- end
30
- elem.replace(x)
31
- end
32
-
33
- def figure1(f)
34
- return sourcecode1(f) if f["class"] == "pseudocode" || f["type"] == "pseudocode"
35
- return if labelled_ancestor(f) && f.ancestors("figure").empty?
36
- return if f.at(ns("./figure")) and !f.at(ns("./name"))
37
-
38
- lbl = @xrefs.anchor(f['id'], :label, false) or return
39
- prefix_name(f, "&nbsp;&mdash; ",
40
- l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
41
- end
42
-
43
- def prefix_name(f, delim, number, elem)
11
+ def prefix_name(node, delim, number, elem)
44
12
  return if number.nil? || number.empty?
45
13
 
46
- unless name = f.at(ns("./#{elem}"))
47
- f.children.empty? and f.add_child("<#{elem}></#{elem}>") or
48
- f.children.first.previous = "<#{elem}></#{elem}>"
49
- name = f.children.first
14
+ unless name = node.at(ns("./#{elem}"))
15
+ node.children.empty? and node.add_child("<#{elem}></#{elem}>") or
16
+ node.children.first.previous = "<#{elem}></#{elem}>"
17
+ name = node.children.first
18
+ end
19
+ if name.children.empty? then name.add_child(number)
20
+ else (name.children.first.previous = "#{number}#{delim}")
50
21
  end
51
- name.children.empty? ? name.add_child(number) :
52
- ( name.children.first.previous = "#{number}#{delim}" )
53
22
  end
54
23
 
55
24
  def sourcecode(docxml)
@@ -58,12 +27,13 @@ module IsoDoc
58
27
  end
59
28
  end
60
29
 
61
- def sourcecode1(f)
62
- return if labelled_ancestor(f)
63
- return unless f.ancestors("example").empty?
30
+ def sourcecode1(elem)
31
+ return if labelled_ancestor(elem)
32
+ return unless elem.ancestors("example").empty?
64
33
 
65
- lbl = @xrefs.anchor(f['id'], :label, false) or return
66
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
34
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
35
+ prefix_name(elem, "&nbsp;&mdash; ",
36
+ l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
67
37
  end
68
38
 
69
39
  def formula(docxml)
@@ -73,9 +43,9 @@ module IsoDoc
73
43
  end
74
44
 
75
45
  # introduce name element
76
- def formula1(f)
77
- lbl = @xrefs.anchor(f['id'], :label, false)
78
- prefix_name(f, "", lbl, "name")
46
+ def formula1(elem)
47
+ lbl = @xrefs.anchor(elem["id"], :label, false)
48
+ prefix_name(elem, "", lbl, "name")
79
49
  end
80
50
 
81
51
  def example(docxml)
@@ -90,11 +60,14 @@ module IsoDoc
90
60
  end
91
61
  end
92
62
 
93
- def example1(f)
94
- n = @xrefs.get[f["id"]]
95
- lbl = (n.nil? || n[:label].nil? || n[:label].empty?) ? @i18n.example:
96
- l10n("#{@i18n.example} #{n[:label]}")
97
- prefix_name(f, "&nbsp;&mdash; ", lbl, "name")
63
+ def example1(elem)
64
+ n = @xrefs.get[elem["id"]]
65
+ lbl = if n.nil? || n[:label].nil? || n[:label].empty?
66
+ @i18n.example
67
+ else
68
+ l10n("#{@i18n.example} #{n[:label]}")
69
+ end
70
+ prefix_name(elem, "&nbsp;&mdash; ", lbl, "name")
98
71
  end
99
72
 
100
73
  def note(docxml)
@@ -104,13 +77,16 @@ module IsoDoc
104
77
  end
105
78
 
106
79
  # introduce name element
107
- def note1(f)
108
- return if f.parent.name == "bibitem"
80
+ def note1(elem)
81
+ return if elem.parent.name == "bibitem"
109
82
 
110
- n = @xrefs.get[f["id"]]
111
- lbl = (@i18n.note if n.nil? || n[:label].nil? || n[:label].empty?) ?
112
- @i18n.note: l10n("#{@i18n.note} #{n[:label]}")
113
- prefix_name(f, "", lbl, "name")
83
+ n = @xrefs.get[elem["id"]]
84
+ lbl = if n.nil? || n[:label].nil? || n[:label].empty?
85
+ @i18n.note
86
+ else
87
+ l10n("#{@i18n.note} #{n[:label]}")
88
+ end
89
+ prefix_name(elem, "", lbl, "name")
114
90
  end
115
91
 
116
92
  def termnote(docxml)
@@ -120,9 +96,27 @@ module IsoDoc
120
96
  end
121
97
 
122
98
  # introduce name element
123
- def termnote1(f)
124
- lbl = l10n(@xrefs.anchor(f["id"], :label) || "???")
125
- prefix_name(f, "", lower2cap(lbl), "name")
99
+ def termnote1(elem)
100
+ lbl = l10n(@xrefs.anchor(elem["id"], :label) || "???")
101
+ prefix_name(elem, "", lower2cap(lbl), "name")
102
+ end
103
+
104
+ def termdefinition(docxml)
105
+ docxml.xpath(ns("//term[definition]")).each do |f|
106
+ termdefinition1(f)
107
+ end
108
+ end
109
+
110
+ def termdefinition1(elem)
111
+ return unless elem.xpath(ns("./definition")).size > 1
112
+
113
+ d = elem.at(ns("./definition"))
114
+ d = d.replace("<ol><li>#{d.children.to_xml}</li></ol>").first
115
+ elem.xpath(ns("./definition")).each do |f|
116
+ f = f.replace("<li>#{f.children.to_xml}</li>").first
117
+ d << f
118
+ end
119
+ d.wrap("<definition></definition>")
126
120
  end
127
121
 
128
122
  def recommendation(docxml)
@@ -144,10 +138,10 @@ module IsoDoc
144
138
  end
145
139
 
146
140
  # introduce name element
147
- def recommendation1(f, type)
148
- n = @xrefs.anchor(f["id"], :label, false)
141
+ def recommendation1(elem, type)
142
+ n = @xrefs.anchor(elem["id"], :label, false)
149
143
  lbl = (n.nil? ? type : l10n("#{type} #{n}"))
150
- prefix_name(f, "", lbl, "name")
144
+ prefix_name(elem, "", lbl, "name")
151
145
  end
152
146
 
153
147
  def table(docxml)
@@ -156,12 +150,13 @@ module IsoDoc
156
150
  end
157
151
  end
158
152
 
159
- def table1(f)
160
- return if labelled_ancestor(f)
161
- return if f["unnumbered"] && !f.at(ns("./name"))
153
+ def table1(elem)
154
+ return if labelled_ancestor(elem)
155
+ return if elem["unnumbered"] && !elem.at(ns("./name"))
162
156
 
163
- n = @xrefs.anchor(f["id"], :label, false)
164
- prefix_name(f, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"), "name")
157
+ n = @xrefs.anchor(elem["id"], :label, false)
158
+ prefix_name(elem, "&nbsp;&mdash; ", l10n("#{lower2cap @i18n.table} #{n}"),
159
+ "name")
165
160
  end
166
161
 
167
162
  # we use this to eliminate the semantic amend blocks from rendering
@@ -171,11 +166,11 @@ module IsoDoc
171
166
  end
172
167
  end
173
168
 
174
- def amend1(f)
175
- f.xpath(ns("./autonumber")).each(&:remove)
176
- f.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
177
- f.xpath(ns("./description")).each { |a| a.replace(a.children) }
178
- f.replace(f.children)
169
+ def amend1(elem)
170
+ elem.xpath(ns("./autonumber")).each(&:remove)
171
+ elem.xpath(ns("./newcontent")).each { |a| a.name = "quote" }
172
+ elem.xpath(ns("./description")).each { |a| a.replace(a.children) }
173
+ elem.replace(elem.children)
179
174
  end
180
175
  end
181
176
  end
@@ -0,0 +1,68 @@
1
+ module IsoDoc
2
+ class PresentationXMLConvert < ::IsoDoc::Convert
3
+ def concept(docxml)
4
+ docxml.xpath(ns("//concept")).each { |f| concept1(f) }
5
+ end
6
+
7
+ def concept1(node)
8
+ xref = node&.at(ns("./xref/@target"))&.text or
9
+ return concept_render(node, ital: node["ital"] || "true",
10
+ ref: node["ref"] || "true",
11
+ linkref: node["linkref"] || "true",
12
+ linkmention: node["linkmention"] || "false")
13
+ if node.at(ns("//definitions//dt[@id = '#{xref}']"))
14
+ concept_render(node, ital: node["ital"] || "false",
15
+ ref: node["ref"] || "false",
16
+ linkref: node["linkref"] || "true",
17
+ linkmention: node["linkmention"] || "false")
18
+ else concept_render(node, ital: node["ital"] || "true",
19
+ ref: node["ref"] || "true",
20
+ linkref: node["linkref"] || "true",
21
+ linkmention: node["linkmention"] || "false")
22
+ end
23
+ end
24
+
25
+ def concept_render(node, opts)
26
+ node&.at(ns("./refterm"))&.remove
27
+ r = node.at(ns("./renderterm"))
28
+ ref = node.at(ns("./xref | ./eref | ./termref"))
29
+ ref && opts[:ref] != "false" and r&.next = " "
30
+ opts[:ital] == "true" and r&.name = "em"
31
+ if opts[:linkmention] == "true" && !r.nil? && !ref.nil?
32
+ ref2 = ref.clone
33
+ r2 = r.clone
34
+ r.replace(ref2).children = r2
35
+ end
36
+ concept1_ref(node, ref, opts)
37
+ if opts[:ital] == "false"
38
+ r = node.at(ns(".//renderterm"))
39
+ r&.replace(r&.children)
40
+ end
41
+ node.replace(node.children)
42
+ end
43
+
44
+ def concept1_ref(_node, ref, opts)
45
+ ref.nil? and return
46
+ return ref.remove if opts[:ref] == "false"
47
+
48
+ r = concept1_ref_content(ref)
49
+ ref = r.at("./descendant-or-self::xmlns:xref | "\
50
+ "./descendant-or-self::xmlns:eref | "\
51
+ "./descendant-or-self::xmlns:termref")
52
+ %w(xref eref).include? ref&.name and get_linkend(ref)
53
+ if opts[:linkref] == "false" && %w(xref eref).include?(ref&.name)
54
+ ref.replace(ref.children)
55
+ end
56
+ end
57
+
58
+ def concept1_ref_content(ref)
59
+ if non_locality_elems(ref).select do |c|
60
+ !c.text? || /\S/.match(c)
61
+ end.empty?
62
+ ref.replace(@i18n.term_defined_in.sub(/%/,
63
+ ref.to_xml))
64
+ else ref.replace("[#{ref.to_xml}]")
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,112 @@
1
+ require "base64"
2
+ require "emf2svg"
3
+
4
+ module IsoDoc
5
+ class PresentationXMLConvert < ::IsoDoc::Convert
6
+ def figure(docxml)
7
+ docxml.xpath(ns("//image")).each { |f| svg_extract(f) }
8
+ docxml.xpath(ns("//figure")).each { |f| figure1(f) }
9
+ docxml.xpath(ns("//svgmap")).each do |s|
10
+ if f = s.at(ns("./figure")) then s.replace(f)
11
+ else s.remove
12
+ end
13
+ end
14
+ docxml.xpath(ns("//image")).each { |f| svg_emf_double(f) }
15
+ end
16
+
17
+ def svg_extract(elem)
18
+ return unless %r{^data:image/svg\+xml;}.match?(elem["src"])
19
+
20
+ svg = Base64.strict_decode64(elem["src"]
21
+ .sub(%r{^data:image/svg\+xml;(charset=[^;]+;)?base64,}, ""))
22
+ x = Nokogiri::XML.fragment(svg.sub(/<\?xml[^>]*>/, "")) do |config|
23
+ config.huge
24
+ end
25
+ elem["src"] = ""
26
+ elem.children = x
27
+ end
28
+
29
+ def figure1(elem)
30
+ return sourcecode1(elem) if elem["class"] == "pseudocode" ||
31
+ elem["type"] == "pseudocode"
32
+ return if labelled_ancestor(elem) && elem.ancestors("figure").empty? ||
33
+ elem.at(ns("./figure")) && !elem.at(ns("./name"))
34
+
35
+ lbl = @xrefs.anchor(elem["id"], :label, false) or return
36
+ prefix_name(elem, "&nbsp;&mdash; ",
37
+ l10n("#{lower2cap @i18n.figure} #{lbl}"), "name")
38
+ end
39
+
40
+ def svg_emf_double(img)
41
+ if emf?(img["mimetype"])
42
+ img = emf_encode(img)
43
+ img.children.first.previous = emf_to_svg(img)
44
+ elsif img["mimetype"] == "image/svg+xml"
45
+ src = svg_to_emf(img) and img << "<emf src='#{src}'/>"
46
+ end
47
+ end
48
+
49
+ def emf_encode(img)
50
+ img["mimetype"] = "image/svg+xml"
51
+ unless %r{^data:image}.match?(img["src"])
52
+ img["src"] = Metanorma::Utils::datauri(img["src"])
53
+ end
54
+ img.children = "<emf src='#{img['src']}'/>"
55
+ img["src"] = ""
56
+ img
57
+ end
58
+
59
+ def emf_to_svg(img)
60
+ emf = Metanorma::Utils::save_dataimage(img.at(ns("./emf/@src")).text)
61
+ Emf2svg.from_file(emf).sub(/<\?[^>]+>/, "")
62
+ end
63
+
64
+ def svg_to_emf(node)
65
+ uri = svg_to_emf_uri(node)
66
+ ret = svg_to_emf_filename(uri)
67
+ File.exists?(ret) and return ret
68
+ exe = inkscape_installed? or return nil
69
+ uri = Metanorma::Utils::external_path uri
70
+ exe = Metanorma::Utils::external_path exe
71
+ system(%(#{exe} --export-type="emf" #{uri})) and
72
+ return Metanorma::Utils::datauri(ret)
73
+
74
+ warn %(Fail on #{exe} --export-type="emf" #{uri})
75
+
76
+ nil
77
+ end
78
+
79
+ def svg_to_emf_uri(node)
80
+ uri = if node&.elements&.first&.name == "svg"
81
+ a = Base64.strict_encode64(node.children.to_xml)
82
+ "data:image/svg+xml;base64,#{a}"
83
+ else node["src"]
84
+ end
85
+ if %r{^data:}.match?(uri)
86
+ uri = save_dataimage(uri)
87
+ @tempfile_cache << uri
88
+ end
89
+ uri
90
+ end
91
+
92
+ def svg_to_emf_filename(uri)
93
+ "#{File.join(File.dirname(uri), File.basename(uri, '.*'))}.emf"
94
+ end
95
+
96
+ def emf_to_svgfilename(uri)
97
+ "#{File.join(File.dirname(uri), File.basename(uri, '.*'))}.svg"
98
+ end
99
+
100
+ def inkscape_installed?
101
+ cmd = "inkscape"
102
+ exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
103
+ ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
104
+ exts.each do |ext|
105
+ exe = File.join(path, "#{cmd}#{ext}")
106
+ return exe if File.executable?(exe) && !File.directory?(exe)
107
+ end
108
+ end
109
+ nil
110
+ end
111
+ end
112
+ end
@@ -1,3 +1,6 @@
1
+ require "metanorma-utils"
2
+ require_relative "./concept"
3
+
1
4
  module IsoDoc
2
5
  class PresentationXMLConvert < ::IsoDoc::Convert
3
6
  def prefix_container(container, linkend, _target)
@@ -67,7 +70,7 @@ module IsoDoc
67
70
  link += eref_localities(node.xpath(ns("./locality | ./localityStack")),
68
71
  link, node)
69
72
  non_locality_elems(node).each(&:remove)
70
- node.add_child(link)
73
+ node.add_child(cleanup_entities(link))
71
74
  end
72
75
  # so not <origin bibitemid="ISO7301" citeas="ISO 7301">
73
76
  # <locality type="section"><reference>3.1</reference></locality></origin>
@@ -88,8 +91,7 @@ module IsoDoc
88
91
  ret += eref_localities0(rr, j, target, delim, node)
89
92
  delim = ","
90
93
  end
91
- else
92
- ret += eref_localities0(ref, idx, target, delim, node)
94
+ else ret += eref_localities0(ref, idx, target, delim, node)
93
95
  end
94
96
  ret
95
97
  end
@@ -130,7 +132,7 @@ module IsoDoc
130
132
  loc = @i18n.locality[type] || type.sub(/^locality:/, "")
131
133
  loc = case node["case"]
132
134
  when "lowercase" then loc.downcase
133
- else loc.capitalize
135
+ else Metanorma::Utils.strict_capitalize_first(loc)
134
136
  end
135
137
  " #{loc}"
136
138
  end
@@ -155,41 +157,6 @@ module IsoDoc
155
157
  get_linkend(node)
156
158
  end
157
159
 
158
- def concept(docxml)
159
- docxml.xpath(ns("//concept")).each { |f| concept1(f) }
160
- end
161
-
162
- def concept1(node)
163
- xref = node&.at(ns("./xref/@target"))&.text or
164
- return concept_render(node, node["ital"] || "true",
165
- node["ref"] || "true")
166
- if node.at(ns("//definitions//dt[@id = '#{xref}']"))
167
- concept_render(node, node["ital"] || "false", node["ref"] || "false")
168
- else concept_render(node, node["ital"] || "true", node["ref"] || "true")
169
- end
170
- end
171
-
172
- def concept_render(node, ital, ref)
173
- node&.at(ns("./refterm"))&.remove
174
- r = node.at(ns("./renderterm"))
175
- r&.next = " " if node.at(ns("./xref | ./eref | ./termref")) && ref != "false"
176
- if ital == "true" then r&.name = "em"
177
- else r&.replace(r&.children)
178
- end
179
- concept1_ref(node, ref)
180
- node.replace(node.children)
181
- end
182
-
183
- def concept1_ref(node, ref)
184
- r = node.at(ns("./xref | ./eref | ./termref")) or return
185
- return r.remove if ref == "false"
186
-
187
- if non_locality_elems(r).select { |c| !c.text? || /\S/.match(c) }.empty?
188
- r.replace(@i18n.term_defined_in.sub(/%/, r.to_xml))
189
- else r.replace("[#{r.to_xml}]")
190
- end
191
- end
192
-
193
160
  def variant(docxml)
194
161
  docxml.xpath(ns("//variant")).each { |f| variant1(f) }
195
162
  docxml.xpath(ns("//variant[@remove = 'true']")).each(&:remove)
@@ -1,5 +1,6 @@
1
1
  require "twitter_cldr"
2
2
  require "bigdecimal"
3
+ require "mathml2asciimath"
3
4
 
4
5
  module IsoDoc
5
6
  class PresentationXMLConvert < ::IsoDoc::Convert
@@ -70,7 +71,15 @@ module IsoDoc
70
71
  locale
71
72
  end
72
73
 
74
+ def asciimath_dup(node)
75
+ return if @suppressasciimathdup
76
+
77
+ a = MathML2AsciiMath.m2a(node.to_xml)
78
+ node.next = "<!-- #{a} -->"
79
+ end
80
+
73
81
  def mathml1(node, locale)
82
+ asciimath_dup(node)
74
83
  localize_maths(node, locale)
75
84
  return unless node.elements.size == 1 && node.elements.first.name == "mn"
76
85
 
@@ -78,12 +78,23 @@ module IsoDoc
78
78
  i = display_order_at(docxml, "//clause[@type = 'scope']", i)
79
79
  i = display_order_at(docxml, @xrefs.klass.norm_ref_xpath, i)
80
80
  i = display_order_at(docxml, "//sections/terms | "\
81
- "//sections/clause[descendant::terms]", i)
81
+ "//sections/clause[descendant::terms]", i)
82
82
  i = display_order_at(docxml, "//sections/definitions", i)
83
83
  i = display_order_xpath(docxml, @xrefs.klass.middle_clause(docxml), i)
84
84
  i = display_order_xpath(docxml, "//annex", i)
85
85
  i = display_order_xpath(docxml, @xrefs.klass.bibliography_xpath, i)
86
86
  display_order_xpath(docxml, "//indexsect", i)
87
87
  end
88
+
89
+ def clausetitle(docxml)
90
+ docxml.xpath(ns("//variant-title[@type = 'toc']")).each(&:remove)
91
+ end
92
+
93
+ def toc(docxml)
94
+ docxml.xpath(ns("//toc//xref[text()]")).each do |x|
95
+ lbl = @xrefs.get[x["target"]][:label] or next
96
+ x.children.first.previous = "#{lbl}<tab/>"
97
+ end
98
+ end
88
99
  end
89
100
  end
@@ -34,6 +34,8 @@ module IsoDoc
34
34
  term docxml
35
35
  references docxml
36
36
  index docxml
37
+ clausetitle docxml
38
+ toc docxml
37
39
  display_order docxml
38
40
  end
39
41
 
@@ -47,6 +49,7 @@ module IsoDoc
47
49
  termexample docxml
48
50
  note docxml
49
51
  termnote docxml
52
+ termdefinition docxml
50
53
  permission docxml
51
54
  requirement docxml
52
55
  recommendation docxml
@@ -1,3 +1,3 @@
1
1
  module IsoDoc
2
- VERSION = "1.7.3".freeze
2
+ VERSION = "1.7.6".freeze
3
3
  end