isodoc 1.7.1 → 1.7.4
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.
- checksums.yaml +4 -4
- data/isodoc.gemspec +2 -1
- data/lib/isodoc/convert.rb +1 -0
- data/lib/isodoc/css.rb +3 -3
- data/lib/isodoc/function/blocks.rb +180 -168
- data/lib/isodoc/function/blocks_example_note.rb +85 -79
- data/lib/isodoc/function/cleanup.rb +181 -175
- data/lib/isodoc/function/inline.rb +110 -108
- data/lib/isodoc/function/inline_simple.rb +55 -55
- data/lib/isodoc/function/lists.rb +75 -71
- data/lib/isodoc/function/references.rb +165 -160
- data/lib/isodoc/function/reqt.rb +91 -85
- data/lib/isodoc/function/section.rb +140 -190
- data/lib/isodoc/function/section_titles.rb +82 -0
- data/lib/isodoc/function/table.rb +90 -87
- data/lib/isodoc/function/terms.rb +58 -56
- data/lib/isodoc/function/to_word_html.rb +208 -204
- data/lib/isodoc/html_convert.rb +0 -4
- data/lib/isodoc/html_function/mathvariant_to_plain.rb +5 -3
- data/lib/isodoc/presentation_function/inline.rb +1 -1
- data/lib/isodoc/presentation_function/math.rb +9 -0
- data/lib/isodoc/presentation_function/section.rb +12 -1
- data/lib/isodoc/presentation_xml_convert.rb +2 -0
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +5 -5
- data/lib/isodoc/xslfo_convert.rb +2 -2
- data/lib/isodoc.rb +2 -1
- data/lib/metanorma/output/base.rb +13 -0
- data/lib/metanorma/output/utils.rb +17 -0
- data/lib/metanorma/output/xslfo.rb +21 -0
- data/lib/metanorma/output.rb +7 -0
- data/spec/assets/outputtest/a.xml +66 -0
- data/spec/assets/outputtest/iso.international-standard.xsl +3011 -0
- data/spec/isodoc/blocks_spec.rb +441 -243
- data/spec/isodoc/inline_spec.rb +197 -114
- data/spec/isodoc/postproc_spec.rb +2 -2
- data/spec/isodoc/presentation_xml_spec.rb +84 -0
- data/spec/isodoc/section_spec.rb +639 -0
- metadata +23 -18
- data/lib/isodoc/html_function/sectionsplit.rb +0 -244
- data/spec/isodoc/sectionsplit_spec.rb +0 -190
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ddab8465c1411d1596aa170ddda0affb869a0989e4fb0351d2b68c4a02e4a07
|
4
|
+
data.tar.gz: 0aaecaa60940f2177781ca3b51610c2be9f0ac0fef3e8f01227b9afba9330571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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"
|
data/lib/isodoc/convert.rb
CHANGED
@@ -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
|
4
|
-
module
|
5
|
-
|
3
|
+
module IsoDoc
|
4
|
+
module Function
|
5
|
+
module Blocks
|
6
|
+
@annotation = false
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def middle_title(_isoxml, out)
|
9
|
+
out.p(**{ class: "zzSTDTitle1" }) { |p| p << @meta.get[:doctitle] }
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
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
|
-
|
18
|
-
|
18
|
+
def figure_name_parse(_node, div, name)
|
19
|
+
return if name.nil?
|
19
20
|
|
20
|
-
|
21
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
-
|
33
|
-
|
32
|
+
def figure_attrs(node)
|
33
|
+
attr_code(id: node["id"], class: "figure", style: keep_style(node))
|
34
|
+
end
|
34
35
|
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
55
|
+
def pseudocode_attrs(node)
|
56
|
+
attr_code(id: node["id"], class: "pseudocode", style: keep_style(node))
|
57
|
+
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
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
|
-
|
65
|
-
|
69
|
+
def sourcecode_name_parse(_node, div, name)
|
70
|
+
return if name.nil?
|
66
71
|
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
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
|
-
|
79
|
-
|
80
|
-
|
83
|
+
def sourcecode_attrs(node)
|
84
|
+
attr_code(id: node["id"], class: "Sourcecode", style: keep_style(node))
|
85
|
+
end
|
81
86
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
93
|
-
|
94
|
-
|
97
|
+
def pre_parse(node, out)
|
98
|
+
out.pre node.text, **attr_code(id: node["id"])
|
99
|
+
end
|
95
100
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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/><#{callout.text}> "
|
108
|
+
out << node&.children&.text&.strip
|
109
|
+
@annotation = false
|
110
|
+
end
|
106
111
|
|
107
|
-
|
108
|
-
|
109
|
-
|
112
|
+
def admonition_class(_node)
|
113
|
+
"Admonition"
|
114
|
+
end
|
110
115
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
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
|
-
|
117
|
-
|
118
|
-
|
121
|
+
name << @i18n.admonition[type]&.upcase
|
122
|
+
name
|
123
|
+
end
|
119
124
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
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
|
-
|
135
|
-
|
139
|
+
def formula_where(dlist, out)
|
140
|
+
return unless dlist
|
136
141
|
|
137
|
-
|
138
|
-
|
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
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
-
|
157
|
-
|
158
|
-
|
161
|
+
def formula_attrs(node)
|
162
|
+
attr_code(id: node["id"], style: keep_style(node))
|
163
|
+
end
|
159
164
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
172
|
+
parse(n, div)
|
173
|
+
end
|
168
174
|
end
|
169
175
|
end
|
170
|
-
end
|
171
176
|
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
+
def para_parse(node, out)
|
193
|
+
out.p **attr_code(para_attrs(node)) do |p|
|
194
|
+
unless @termdomain.empty?
|
195
|
+
p << "<#{@termdomain}> "
|
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
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
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
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
207
|
+
out.p **{ class: "QuoteAttribution" } do |p|
|
208
|
+
p << "— #{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
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
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
|
-
|
221
|
-
|
222
|
-
|
225
|
+
def passthrough_parse(node, out)
|
226
|
+
return if node["format"] &&
|
227
|
+
!(node["format"].split(",").include? @format.to_s)
|
223
228
|
|
224
|
-
|
225
|
-
|
229
|
+
out.passthrough node.text
|
230
|
+
end
|
226
231
|
|
227
|
-
|
228
|
-
|
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
|