isodoc 1.7.1 → 1.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/isodoc.gemspec +2 -1
  3. data/lib/isodoc/convert.rb +1 -0
  4. data/lib/isodoc/css.rb +3 -3
  5. data/lib/isodoc/function/blocks.rb +180 -168
  6. data/lib/isodoc/function/blocks_example_note.rb +85 -79
  7. data/lib/isodoc/function/cleanup.rb +181 -175
  8. data/lib/isodoc/function/inline.rb +110 -108
  9. data/lib/isodoc/function/inline_simple.rb +55 -55
  10. data/lib/isodoc/function/lists.rb +75 -71
  11. data/lib/isodoc/function/references.rb +165 -160
  12. data/lib/isodoc/function/reqt.rb +91 -85
  13. data/lib/isodoc/function/section.rb +140 -190
  14. data/lib/isodoc/function/section_titles.rb +82 -0
  15. data/lib/isodoc/function/table.rb +90 -87
  16. data/lib/isodoc/function/terms.rb +58 -56
  17. data/lib/isodoc/function/to_word_html.rb +208 -204
  18. data/lib/isodoc/html_convert.rb +0 -4
  19. data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
  20. data/lib/isodoc/presentation_function/inline.rb +1 -1
  21. data/lib/isodoc/presentation_function/math.rb +9 -0
  22. data/lib/isodoc/presentation_function/section.rb +12 -1
  23. data/lib/isodoc/presentation_xml_convert.rb +2 -0
  24. data/lib/isodoc/version.rb +1 -1
  25. data/lib/isodoc/word_function/body.rb +5 -5
  26. data/lib/isodoc/xslfo_convert.rb +2 -2
  27. data/lib/isodoc.rb +2 -1
  28. data/lib/metanorma/output/base.rb +13 -0
  29. data/lib/metanorma/output/utils.rb +17 -0
  30. data/lib/metanorma/output/xslfo.rb +21 -0
  31. data/lib/metanorma/output.rb +7 -0
  32. data/spec/assets/outputtest/a.xml +66 -0
  33. data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
  34. data/spec/isodoc/blocks_spec.rb +441 -243
  35. data/spec/isodoc/inline_spec.rb +197 -114
  36. data/spec/isodoc/postproc_spec.rb +2 -2
  37. data/spec/isodoc/presentation_xml_spec.rb +84 -0
  38. data/spec/isodoc/section_spec.rb +639 -0
  39. metadata +23 -18
  40. data/lib/isodoc/html_function/sectionsplit.rb +0 -244
  41. data/spec/isodoc/sectionsplit_spec.rb +0 -190
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b64ad76ffcf7c9f1ced2c15c41a263e49e62cfa4294d31066ba2e358e613fb35
4
- data.tar.gz: f35ca08d240ae7cdb7ba9aa0c9e071ec284d051f0d61c82542d461e101d0da38
3
+ metadata.gz: 9ddab8465c1411d1596aa170ddda0affb869a0989e4fb0351d2b68c4a02e4a07
4
+ data.tar.gz: 0aaecaa60940f2177781ca3b51610c2be9f0ac0fef3e8f01227b9afba9330571
5
5
  SHA512:
6
- metadata.gz: 3062ddc15478efad6f25fb39e37689fecab84750b34c2496f5693af1b52c864053f50acf3af141d876e8cb8d2d19f89ecdd19e630ab1b1da9e953e897f2ab68a
7
- data.tar.gz: 14d688526a710b92cf2256e49df75e4abcf5a67ed7de40e6593cedf1a99e96561ba5024398ae7c767d78a4e0d74e18df344423cfbc83dd75e2afa28beeea0006
6
+ metadata.gz: ab482ce07d9ff45b532e3ffa83f98334171e75d5c91eded8c81070b2065690ee2cd1b246fe63ce55a61e04a3fe11fd259cdf1e800885a1151003add5fca1e41b
7
+ data.tar.gz: 77df20df67c7adb582dbbfb4a69ec8198d5d811ebe490d08bd023a4e3261083f64da759ca2d1fa231cb3dba3e7b254d7a1331a3e6b3a085ed9586fc1a81b0778
data/isodoc.gemspec CHANGED
@@ -32,13 +32,14 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency "html2doc", "~> 1.1.1"
33
33
  spec.add_dependency "htmlentities", "~> 4.3.4"
34
34
  spec.add_dependency "liquid", "~> 4"
35
- spec.add_dependency "metanorma", ">= 1.2.0"
35
+ #spec.add_dependency "metanorma", ">= 1.2.0"
36
36
  spec.add_dependency "nokogiri", "~> 1.11.0"
37
37
  spec.add_dependency "relaton-cli"
38
38
  spec.add_dependency "roman-numerals"
39
39
  spec.add_dependency "thread_safe"
40
40
  spec.add_dependency "twitter_cldr", ">= 6.6.0"
41
41
  spec.add_dependency "uuidtools"
42
+ spec.add_dependency "mathml2asciimath"
42
43
 
43
44
  spec.add_development_dependency "byebug", "~> 9.1"
44
45
  spec.add_development_dependency "equivalent-xml", "~> 0.6"
@@ -75,6 +75,7 @@ module IsoDoc
75
75
  @suppressheadingnumbers = options[:suppressheadingnumbers]
76
76
  @break_up_urls_in_tables = options[:break_up_urls_in_tables] == "true"
77
77
  @sectionsplit = options[:sectionsplit] == "true"
78
+ @suppressasciimathdup = options[:suppressasciimathdup] == "true"
78
79
  @bare = options[:bare]
79
80
  @termdomain = ""
80
81
  @termexample = false
data/lib/isodoc/css.rb CHANGED
@@ -39,7 +39,7 @@ module IsoDoc
39
39
  {
40
40
  bodyfont: "Arial",
41
41
  headerfont: "Arial",
42
- monospacefont: "Courier",
42
+ monospacefont: "Courier New",
43
43
  }
44
44
  end
45
45
 
@@ -53,7 +53,7 @@ module IsoDoc
53
53
  {
54
54
  "bodyfont" => options[:bodyfont] || "Arial",
55
55
  "headerfont" => options[:headerfont] || "Arial",
56
- "monospacefont" => options[:monospacefont] || "Courier",
56
+ "monospacefont" => options[:monospacefont] || "Courier New",
57
57
  "normalfontsize" => options[:normalfontsize],
58
58
  "monospacefontsize" => options[:monospacefontsize],
59
59
  "smallerfontsize" => options[:smallerfontsize],
@@ -64,7 +64,7 @@ module IsoDoc
64
64
  def scss_fontheader(is_html_css)
65
65
  b = options[:bodyfont] || "Arial"
66
66
  h = options[:headerfont] || "Arial"
67
- m = options[:monospacefont] || "Courier"
67
+ m = options[:monospacefont] || "Courier New"
68
68
  ns = options[:normalfontsize] || (is_html_css ? "1.0em" : "12.0pt")
69
69
  ms = options[:monospacefontsize] || (is_html_css ? "0.8em" : "11.0pt")
70
70
  ss = options[:smallerfontsize] || (is_html_css ? "0.9em" : "10.0pt")
@@ -1,231 +1,243 @@
1
1
  require_relative "blocks_example_note"
2
2
 
3
- module IsoDoc::Function
4
- module Blocks
5
- @annotation = false
3
+ module IsoDoc
4
+ module Function
5
+ module Blocks
6
+ @annotation = false
6
7
 
7
- def middle_title(_isoxml, out)
8
- out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
9
- end
8
+ def middle_title(_isoxml, out)
9
+ out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
10
+ end
10
11
 
11
- def middle_admonitions(isoxml, out)
12
- isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
13
- parse(x, out)
12
+ def middle_admonitions(isoxml, out)
13
+ isoxml.xpath(ns("//sections/note | //sections/admonition")).each do |x|
14
+ parse(x, out)
15
+ end
14
16
  end
15
- end
16
17
 
17
- def figure_name_parse(_node, div, name)
18
- return if name.nil?
18
+ def figure_name_parse(_node, div, name)
19
+ return if name.nil?
19
20
 
20
- div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
21
- name.children.each { |n| parse(n, p) }
21
+ div.p **{ class: "FigureTitle", style: "text-align:center;" } do |p|
22
+ name.children.each { |n| parse(n, p) }
23
+ end
22
24
  end
23
- end
24
25
 
25
- def figure_key(out)
26
- out.p **{ style: "page-break-after:avoid;" } do |p|
27
- p.b { |b| b << @i18n.key }
26
+ def figure_key(out)
27
+ out.p **{ style: "page-break-after:avoid;" } do |p|
28
+ p.b { |b| b << @i18n.key }
29
+ end
28
30
  end
29
- end
30
31
 
31
- def figure_attrs(node)
32
- attr_code(id: node["id"], class: "figure", style: keep_style(node))
33
- end
32
+ def figure_attrs(node)
33
+ attr_code(id: node["id"], class: "figure", style: keep_style(node))
34
+ end
34
35
 
35
- def figure_parse(node, out)
36
- return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
37
- node["type"] == "pseudocode"
36
+ def figure_parse(node, out)
37
+ return pseudocode_parse(node, out) if node["class"] == "pseudocode" ||
38
+ node["type"] == "pseudocode"
39
+
40
+ @in_figure = true
41
+ figure_parse1(node, out)
42
+ @in_figure = false
43
+ end
38
44
 
39
- @in_figure = true
40
- out.div **figure_attrs(node) do |div|
41
- node.children.each do |n|
42
- figure_key(out) if n.name == "dl"
43
- parse(n, div) unless n.name == "name"
45
+ def figure_parse1(node, out)
46
+ out.div **figure_attrs(node) do |div|
47
+ node.children.each do |n|
48
+ figure_key(out) if n.name == "dl"
49
+ parse(n, div) unless n.name == "name"
50
+ end
51
+ figure_name_parse(node, div, node.at(ns("./name")))
44
52
  end
45
- figure_name_parse(node, div, node.at(ns("./name")))
46
53
  end
47
- @in_figure = false
48
- end
49
54
 
50
- def pseudocode_attrs(node)
51
- attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
52
- end
55
+ def pseudocode_attrs(node)
56
+ attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
57
+ end
53
58
 
54
- def pseudocode_parse(node, out)
55
- @in_figure = true
56
- name = node.at(ns("./name"))
57
- out.div **pseudocode_attrs(node) do |div|
58
- node.children.each { |n| parse(n, div) unless n.name == "name" }
59
- sourcecode_name_parse(node, div, name)
59
+ def pseudocode_parse(node, out)
60
+ @in_figure = true
61
+ name = node.at(ns("./name"))
62
+ out.div **pseudocode_attrs(node) do |div|
63
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
64
+ sourcecode_name_parse(node, div, name)
65
+ end
66
+ @in_figure = false
60
67
  end
61
- @in_figure = false
62
- end
63
68
 
64
- def sourcecode_name_parse(_node, div, name)
65
- return if name.nil?
69
+ def sourcecode_name_parse(_node, div, name)
70
+ return if name.nil?
66
71
 
67
- div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
68
- name.children.each { |n| parse(n, p) }
72
+ div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
73
+ name.children.each { |n| parse(n, p) }
74
+ end
69
75
  end
70
- end
71
76
 
72
- def admonition_name_parse(_node, div, name)
73
- div.p **{ class: "AdmonitionTitle", style: "text-align:center;" } do |p|
74
- name.children.each { |n| parse(n, p) }
77
+ def admonition_name_parse(_node, div, name)
78
+ div.p **{ class: "AdmonitionTitle", style: "text-align:center;" } do |p|
79
+ name.children.each { |n| parse(n, p) }
80
+ end
75
81
  end
76
- end
77
82
 
78
- def sourcecode_attrs(node)
79
- attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
80
- end
83
+ def sourcecode_attrs(node)
84
+ attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
85
+ end
81
86
 
82
- def sourcecode_parse(node, out)
83
- name = node.at(ns("./name"))
84
- out.p **sourcecode_attrs(node) do |div|
85
- @sourcecode = true
86
- node.children.each { |n| parse(n, div) unless n.name == "name" }
87
- @sourcecode = false
87
+ def sourcecode_parse(node, out)
88
+ name = node.at(ns("./name"))
89
+ out.p **sourcecode_attrs(node) do |div|
90
+ @sourcecode = true
91
+ node.children.each { |n| parse(n, div) unless n.name == "name" }
92
+ @sourcecode = false
93
+ end
94
+ sourcecode_name_parse(node, out, name)
88
95
  end
89
- sourcecode_name_parse(node, out, name)
90
- end
91
96
 
92
- def pre_parse(node, out)
93
- out.pre node.text, **attr_code(id: node["id"])
94
- end
97
+ def pre_parse(node, out)
98
+ out.pre node.text, **attr_code(id: node["id"])
99
+ end
95
100
 
96
- def annotation_parse(node, out)
97
- @sourcecode = false
98
- @annotation = true
99
- node.at("./preceding-sibling::*[local-name() = 'annotation']") or
100
- out << "<br/>"
101
- callout = node.at(ns("//callout[@target='#{node['id']}']"))
102
- out << "<br/>&lt;#{callout.text}&gt; "
103
- out << node&.children&.text&.strip
104
- @annotation = false
105
- end
101
+ def annotation_parse(node, out)
102
+ @sourcecode = false
103
+ @annotation = true
104
+ node.at("./preceding-sibling::*[local-name() = 'annotation']") or
105
+ out << "<br/>"
106
+ callout = node.at(ns("//callout[@target='#{node['id']}']"))
107
+ out << "<br/>&lt;#{callout.text}&gt; "
108
+ out << node&.children&.text&.strip
109
+ @annotation = false
110
+ end
106
111
 
107
- def admonition_class(_node)
108
- "Admonition"
109
- end
112
+ def admonition_class(_node)
113
+ "Admonition"
114
+ end
110
115
 
111
- def admonition_name(node, type)
112
- name = node&.at(ns("./name")) and return name
113
- name = Nokogiri::XML::Node.new("name", node.document)
114
- return unless type && @i18n.admonition[type]
116
+ def admonition_name(node, type)
117
+ name = node&.at(ns("./name")) and return name
118
+ name = Nokogiri::XML::Node.new("name", node.document)
119
+ return unless type && @i18n.admonition[type]
115
120
 
116
- name << @i18n.admonition[type]&.upcase
117
- name
118
- end
121
+ name << @i18n.admonition[type]&.upcase
122
+ name
123
+ end
119
124
 
120
- def admonition_attrs(node)
121
- attr_code(id: node["id"], class: admonition_class(node),
122
- style: keep_style(node))
123
- end
125
+ def admonition_attrs(node)
126
+ attr_code(id: node["id"], class: admonition_class(node),
127
+ style: keep_style(node))
128
+ end
124
129
 
125
- def admonition_parse(node, out)
126
- type = node["type"]
127
- name = admonition_name(node, type)
128
- out.div **admonition_attrs(node) do |t|
129
- admonition_name_parse(node, t, name) if name
130
- node.children.each { |n| parse(n, t) unless n.name == "name" }
130
+ def admonition_parse(node, out)
131
+ type = node["type"]
132
+ name = admonition_name(node, type)
133
+ out.div **admonition_attrs(node) do |t|
134
+ admonition_name_parse(node, t, name) if name
135
+ node.children.each { |n| parse(n, t) unless n.name == "name" }
136
+ end
131
137
  end
132
- end
133
138
 
134
- def formula_where(dl, out)
135
- return unless dl
139
+ def formula_where(dlist, out)
140
+ return unless dlist
136
141
 
137
- out.p **{ style: "page-break-after:avoid;" } do |p|
138
- p << @i18n.where
142
+ out.p **{ style: "page-break-after:avoid;" } do |p|
143
+ p << @i18n.where
144
+ end
145
+ parse(dlist, out)
146
+ out.parent.at("./dl")["class"] = "formula_dl"
139
147
  end
140
- parse(dl, out)
141
- out.parent.at("./dl")["class"] = "formula_dl"
142
- end
143
148
 
144
- def formula_parse1(node, out)
145
- out.div **attr_code(class: "formula") do |div|
146
- div.p do |_p|
147
- parse(node.at(ns("./stem")), div)
148
- if lbl = node&.at(ns("./name"))&.text
149
- insert_tab(div, 1)
150
- div << "(#{lbl})"
149
+ def formula_parse1(node, out)
150
+ out.div **attr_code(class: "formula") do |div|
151
+ div.p do |_p|
152
+ parse(node.at(ns("./stem")), div)
153
+ if lbl = node&.at(ns("./name"))&.text
154
+ insert_tab(div, 1)
155
+ div << "(#{lbl})"
156
+ end
151
157
  end
152
158
  end
153
159
  end
154
- end
155
160
 
156
- def formula_attrs(node)
157
- attr_code(id: node["id"], style: keep_style(node))
158
- end
161
+ def formula_attrs(node)
162
+ attr_code(id: node["id"], style: keep_style(node))
163
+ end
159
164
 
160
- def formula_parse(node, out)
161
- out.div **formula_attrs(node) do |div|
162
- formula_parse1(node, div)
163
- formula_where(node.at(ns("./dl")), div)
164
- node.children.each do |n|
165
- next if %w(stem dl name).include? n.name
165
+ def formula_parse(node, out)
166
+ out.div **formula_attrs(node) do |div|
167
+ formula_parse1(node, div)
168
+ formula_where(node.at(ns("./dl")), div)
169
+ node.children.each do |n|
170
+ next if %w(stem dl name).include? n.name
166
171
 
167
- parse(n, div)
172
+ parse(n, div)
173
+ end
168
174
  end
169
175
  end
170
- end
171
176
 
172
- def para_class(_node)
173
- classtype = nil
174
- classtype = "MsoCommentText" if in_comment
175
- classtype = "Sourcecode" if @annotation
176
- classtype
177
- end
177
+ def para_class(_node)
178
+ classtype = nil
179
+ classtype = "MsoCommentText" if in_comment
180
+ classtype = "Sourcecode" if @annotation
181
+ classtype
182
+ end
178
183
 
179
- def para_attrs(node)
180
- attrs = { class: para_class(node), id: node["id"] }
181
- s = node["align"].nil? ? "" : "text-align:#{node['align']};"
182
- s = "#{s}#{keep_style(node)}"
183
- attrs[:style] = s unless s.empty?
184
- attrs
185
- end
184
+ def para_attrs(node)
185
+ attrs = { class: para_class(node), id: node["id"] }
186
+ s = node["align"].nil? ? "" : "text-align:#{node['align']};"
187
+ s = "#{s}#{keep_style(node)}"
188
+ attrs[:style] = s unless s.empty?
189
+ attrs
190
+ end
186
191
 
187
- def para_parse(node, out)
188
- out.p **attr_code(para_attrs(node)) do |p|
189
- unless @termdomain.empty?
190
- p << "&lt;#{@termdomain}&gt; "
191
- @termdomain = ""
192
+ def para_parse(node, out)
193
+ out.p **attr_code(para_attrs(node)) do |p|
194
+ unless @termdomain.empty?
195
+ p << "&lt;#{@termdomain}&gt; "
196
+ @termdomain = ""
197
+ end
198
+ node.children.each { |n| parse(n, p) }
192
199
  end
193
- node.children.each { |n| parse(n, p) }
194
200
  end
195
- end
196
201
 
197
- def quote_attribution(node, out)
198
- author = node.at(ns("./author"))
199
- source = node.at(ns("./source"))
200
- return if author.nil? && source.nil?
202
+ def quote_attribution(node, out)
203
+ author = node.at(ns("./author"))
204
+ source = node.at(ns("./source"))
205
+ return if author.nil? && source.nil?
201
206
 
202
- out.p **{ class: "QuoteAttribution" } do |p|
203
- p << "&mdash; #{author.text}" if author
204
- p << ", " if author && source
205
- eref_parse(source, p) if source
207
+ out.p **{ class: "QuoteAttribution" } do |p|
208
+ p << "&mdash; #{author.text}" if author
209
+ p << ", " if author && source
210
+ eref_parse(source, p) if source
211
+ end
206
212
  end
207
- end
208
213
 
209
- def quote_parse(node, out)
210
- attrs = para_attrs(node)
211
- attrs[:class] = "Quote"
212
- out.div **attr_code(attrs) do |p|
213
- node.children.each do |n|
214
- parse(n, p) unless ["author", "source"].include? n.name
214
+ def quote_parse(node, out)
215
+ attrs = para_attrs(node)
216
+ attrs[:class] = "Quote"
217
+ out.div **attr_code(attrs) do |p|
218
+ node.children.each do |n|
219
+ parse(n, p) unless %w(author source).include? n.name
220
+ end
221
+ quote_attribution(node, out)
215
222
  end
216
- quote_attribution(node, out)
217
223
  end
218
- end
219
224
 
220
- def passthrough_parse(node, out)
221
- return if node["format"] &&
222
- !(node["format"].split(",").include? @format.to_s)
225
+ def passthrough_parse(node, out)
226
+ return if node["format"] &&
227
+ !(node["format"].split(",").include? @format.to_s)
223
228
 
224
- out.passthrough node.text
225
- end
229
+ out.passthrough node.text
230
+ end
226
231
 
227
- def svg_parse(node, out)
228
- out.parent.add_child(node)
232
+ def svg_parse(node, out)
233
+ out.parent.add_child(node)
234
+ end
235
+
236
+ def toc_parse(node, out)
237
+ out.div **{ class: "toc" } do |div|
238
+ node.children.each { |n| parse(n, div) }
239
+ end
240
+ end
229
241
  end
230
242
  end
231
243
  end