isodoc 1.0.9 → 1.0.10
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/Gemfile.lock +4 -4
- data/lib/isodoc/convert.rb +5 -3
- data/lib/isodoc/function/blocks.rb +9 -3
- data/lib/isodoc/function/inline.rb +11 -0
- data/lib/isodoc/function/to_word_html.rb +3 -3
- data/lib/isodoc/function/utils.rb +13 -3
- data/lib/isodoc/function/xref_gen.rb +2 -2
- data/lib/isodoc/html_function/html.rb +0 -10
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +2 -0
- data/lib/isodoc/word_function/footnotes.rb +24 -3
- data/lib/isodoc/word_function/postprocess.rb +5 -9
- data/spec/isodoc/blocks_spec.rb +16 -6
- data/spec/isodoc/footnotes_spec.rb +60 -33
- data/spec/isodoc/inline_spec.rb +47 -0
- data/spec/isodoc/postproc_spec.rb +2 -2
- data/spec/isodoc/xref_spec.rb +49 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acde5067685a87b3ab6d60d0db7d0d0bb41258ee9569248487fea64ad9bdc6bb
|
4
|
+
data.tar.gz: 8afea86b4d65ed1dc140d598e3e9bf84fe1f6025edfd6287e266e5f725d58044
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c989302746ce89015f7dc719b5df66b2b3a8c27e498aa20471bf7e9631a1a80cc0914226b7e6d0778b4b792e9d91d0ea29eb84f07ec14fd646e6800999f5e1a3
|
7
|
+
data.tar.gz: ae33822c3445e57c08b2b0f8bc575e635c88cd7e071af6c93f04b039a1c5375de1deb7373984b9d7877c39a37542f9ef4a3e3f33dcbddf7316c71eb5bb55daaf
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
isodoc (1.0.
|
4
|
+
isodoc (1.0.10)
|
5
5
|
asciimath
|
6
6
|
html2doc (~> 0.9.0)
|
7
7
|
htmlentities (~> 4.3.4)
|
@@ -52,9 +52,9 @@ GEM
|
|
52
52
|
uuidtools
|
53
53
|
htmlentities (4.3.4)
|
54
54
|
image_size (2.0.2)
|
55
|
-
json (2.
|
55
|
+
json (2.3.0)
|
56
56
|
liquid (4.0.3)
|
57
|
-
listen (3.2.
|
57
|
+
listen (3.2.1)
|
58
58
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
59
59
|
rb-inotify (~> 0.9, >= 0.9.10)
|
60
60
|
lumberjack (1.0.13)
|
@@ -67,7 +67,7 @@ GEM
|
|
67
67
|
mime-types-data (3.2019.1009)
|
68
68
|
mini_portile2 (2.4.0)
|
69
69
|
nenv (0.3.0)
|
70
|
-
nokogiri (1.10.
|
70
|
+
nokogiri (1.10.7)
|
71
71
|
mini_portile2 (~> 2.4.0)
|
72
72
|
notiffany (0.1.3)
|
73
73
|
nenv (~> 0.1)
|
data/lib/isodoc/convert.rb
CHANGED
@@ -6,7 +6,7 @@ require "tempfile"
|
|
6
6
|
module IsoDoc
|
7
7
|
class Convert < ::IsoDoc::Common
|
8
8
|
attr_reader :options
|
9
|
-
|
9
|
+
attr_accessor :labels
|
10
10
|
|
11
11
|
# htmlstylesheet: Generic stylesheet for HTML
|
12
12
|
# wordstylesheet: Generic stylesheet for Word
|
@@ -71,6 +71,8 @@ module IsoDoc
|
|
71
71
|
@wordToClevels = 2 if @wordToClevels == 0
|
72
72
|
@htmlToClevels = options[:htmltoclevels].to_i
|
73
73
|
@htmlToClevels = 2 if @htmlToClevels == 0
|
74
|
+
@bookmarks_allocated = {"X" => true}
|
75
|
+
@fn_bookmarks = {}
|
74
76
|
end
|
75
77
|
|
76
78
|
# run this after @meta is populated
|
@@ -136,10 +138,10 @@ module IsoDoc
|
|
136
138
|
#@files_to_delete << outname
|
137
139
|
#outname
|
138
140
|
Tempfile.open([File.basename(filename, ".*"), "css"],
|
139
|
-
|
141
|
+
:encoding => "utf-8") do |f|
|
140
142
|
f.write(engine.render)
|
141
143
|
f
|
142
|
-
|
144
|
+
end
|
143
145
|
end
|
144
146
|
|
145
147
|
def convert1(docxml, filename, dir)
|
@@ -128,9 +128,14 @@ module IsoDoc::Function
|
|
128
128
|
example_div_parse(node, out)
|
129
129
|
end
|
130
130
|
|
131
|
-
def sourcecode_name_parse(
|
131
|
+
def sourcecode_name_parse(node, div, name)
|
132
132
|
div.p **{ class: "SourceTitle", style: "text-align:center;" } do |p|
|
133
|
-
|
133
|
+
if node.ancestors("example").empty?
|
134
|
+
lbl = anchor(node['id'], :label, false)
|
135
|
+
lbl.nil? or p << l10n("#{@figure_lbl} #{lbl}")
|
136
|
+
name and !lbl.nil? and p << " — "
|
137
|
+
end
|
138
|
+
name&.children&.each { |n| parse(n, p) }
|
134
139
|
end
|
135
140
|
end
|
136
141
|
|
@@ -147,7 +152,8 @@ module IsoDoc::Function
|
|
147
152
|
node.children.each { |n| parse(n, div) unless n.name == "name" }
|
148
153
|
@sourcecode = false
|
149
154
|
end
|
150
|
-
sourcecode_name_parse(node, out, name) if name
|
155
|
+
sourcecode_name_parse(node, out, name) if name ||
|
156
|
+
node.ancestors("example").empty? && anchor(node['id'], :label, false)
|
151
157
|
end
|
152
158
|
|
153
159
|
def pre_parse(node, out)
|
@@ -8,6 +8,17 @@ module IsoDoc::Function
|
|
8
8
|
out.br
|
9
9
|
end
|
10
10
|
|
11
|
+
def hr_parse(node, out)
|
12
|
+
out.hr
|
13
|
+
end
|
14
|
+
|
15
|
+
def br_parse(node, out)
|
16
|
+
out.br
|
17
|
+
end
|
18
|
+
|
19
|
+
def index_parse(node, out)
|
20
|
+
end
|
21
|
+
|
11
22
|
def link_parse(node, out)
|
12
23
|
out.a **attr_code(href: node["target"], title: node["alt"]) do |l|
|
13
24
|
if node.text.empty?
|
@@ -193,14 +193,13 @@ module IsoDoc::Function
|
|
193
193
|
when "strike" then strike_parse(node, out)
|
194
194
|
when "keyword" then keyword_parse(node, out)
|
195
195
|
when "smallcap" then smallcap_parse(node, out)
|
196
|
-
when "br" then out
|
197
|
-
when "hr" then out
|
196
|
+
when "br" then br_parse(node, out)
|
197
|
+
when "hr" then hr_parse(node, out)
|
198
198
|
when "bookmark" then bookmark_parse(node, out)
|
199
199
|
when "pagebreak" then page_break(out)
|
200
200
|
when "callout" then callout_parse(node, out)
|
201
201
|
when "stem" then stem_parse(node, out)
|
202
202
|
when "clause" then clause_parse(node, out)
|
203
|
-
#when "appendix" then clause_parse(node, out)
|
204
203
|
when "xref" then xref_parse(node, out)
|
205
204
|
when "eref" then eref_parse(node, out)
|
206
205
|
when "origin" then eref_parse(node, out)
|
@@ -249,6 +248,7 @@ module IsoDoc::Function
|
|
249
248
|
when "measurement-target" then requirement_component_parse(node, out)
|
250
249
|
when "verification" then requirement_component_parse(node, out)
|
251
250
|
when "import" then requirement_component_parse(node, out)
|
251
|
+
when "index" then index_parse(node, out)
|
252
252
|
else
|
253
253
|
error_parse(node, out)
|
254
254
|
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module IsoDoc::Function
|
2
2
|
module Utils
|
3
|
-
|
4
3
|
def date_range(date)
|
5
4
|
self.class.date_range(date)
|
6
5
|
end
|
@@ -40,8 +39,8 @@ module IsoDoc::Function
|
|
40
39
|
end.to_h
|
41
40
|
end
|
42
41
|
|
43
|
-
DOCTYPE_HDR = '<!DOCTYPE html SYSTEM
|
44
|
-
|
42
|
+
DOCTYPE_HDR = '<!DOCTYPE html SYSTEM '\
|
43
|
+
'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'.freeze
|
45
44
|
|
46
45
|
def to_xhtml(xml)
|
47
46
|
xml.gsub!(/<\?xml[^>]*>/, "")
|
@@ -115,6 +114,7 @@ module IsoDoc::Function
|
|
115
114
|
x.replace(" ") if x.name == "span" && /mso-tab-count/.match(x["style"])
|
116
115
|
x.remove if x.name == "span" && x["class"] == "MsoCommentReference"
|
117
116
|
x.remove if x.name == "a" && x["epub:type"] == "footnote"
|
117
|
+
x.remove if x.name == "span" && /mso-bookmark/.match(x["style"])
|
118
118
|
x.replace(x.children) if x.name == "a"
|
119
119
|
end
|
120
120
|
from_xhtml(h1)
|
@@ -164,7 +164,17 @@ module IsoDoc::Function
|
|
164
164
|
f.write(Base64.strict_decode64(imgdata))
|
165
165
|
@tempfile_cache << f #persist to the end
|
166
166
|
f.path
|
167
|
+
end
|
167
168
|
end
|
169
|
+
|
170
|
+
def image_localfile(i)
|
171
|
+
if /^data:image/.match i["src"]
|
172
|
+
save_dataimage(i["src"], false)
|
173
|
+
elsif %r{^([A-Z]:)?/}.match i["src"]
|
174
|
+
i["src"]
|
175
|
+
else
|
176
|
+
File.join(@localdir, i["src"])
|
177
|
+
end
|
168
178
|
end
|
169
179
|
end
|
170
180
|
end
|
@@ -127,7 +127,7 @@ module IsoDoc::Function
|
|
127
127
|
def sequential_figure_names(clause)
|
128
128
|
c = Counter.new
|
129
129
|
j = 0
|
130
|
-
clause.xpath(ns(".//figure[not(
|
130
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
|
131
131
|
if t.parent.name == "figure" then j += 1
|
132
132
|
else
|
133
133
|
j = 0
|
@@ -209,7 +209,7 @@ module IsoDoc::Function
|
|
209
209
|
def hierarchical_figure_names(clause, num)
|
210
210
|
c = Counter.new
|
211
211
|
j = 0
|
212
|
-
clause.xpath(ns(".//figure[not(
|
212
|
+
clause.xpath(ns(".//figure | .//sourcecode[not(ancestor::example)]")).each do |t|
|
213
213
|
if t.parent.name == "figure" then j += 1
|
214
214
|
else
|
215
215
|
j = 0
|
@@ -257,16 +257,6 @@ module IsoDoc::HtmlFunction
|
|
257
257
|
docxml
|
258
258
|
end
|
259
259
|
|
260
|
-
def image_localfile(i)
|
261
|
-
if /^data:image/.match i["src"]
|
262
|
-
save_dataimage(i["src"], false)
|
263
|
-
elsif %r{^([A-Z]:)?/}.match i["src"]
|
264
|
-
i["src"]
|
265
|
-
else
|
266
|
-
File.join(@localdir, i["src"])
|
267
|
-
end
|
268
|
-
end
|
269
|
-
|
270
260
|
def datauri(i)
|
271
261
|
type = i["src"].split(".")[-1]
|
272
262
|
bin = IO.binread(image_localfile(i))
|
data/lib/isodoc/version.rb
CHANGED
@@ -10,6 +10,7 @@ module IsoDoc::WordFunction
|
|
10
10
|
super
|
11
11
|
end
|
12
12
|
|
13
|
+
=begin
|
13
14
|
def anchor_names(docxml)
|
14
15
|
super
|
15
16
|
renumber_footnotes(docxml)
|
@@ -22,6 +23,7 @@ module IsoDoc::WordFunction
|
|
22
23
|
f["reference"] = (i + 1).to_s
|
23
24
|
end
|
24
25
|
end
|
26
|
+
=end
|
25
27
|
|
26
28
|
def body_attr
|
27
29
|
{ lang: "EN-US", link: "blue", vlink: "#954F72" }
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module IsoDoc::WordFunction
|
2
2
|
module Footnotes
|
3
|
+
def bookmarkid
|
4
|
+
ret = "X"
|
5
|
+
until !@bookmarks_allocated[ret] do
|
6
|
+
ret = Random.rand(1000000000)
|
7
|
+
end
|
8
|
+
@bookmarks_allocated[ret] = true
|
9
|
+
sprintf "%09d", ret
|
10
|
+
end
|
3
11
|
|
4
12
|
def footnotes(div)
|
5
13
|
return if @footnotes.empty?
|
@@ -59,13 +67,26 @@ module IsoDoc::WordFunction
|
|
59
67
|
@seen_footnote << (tid + fn)
|
60
68
|
end
|
61
69
|
|
70
|
+
def seen_footnote_parse(node, out, fn)
|
71
|
+
out.span **{style: "mso-element:field-begin"}
|
72
|
+
out << " NOTEREF _Ref#{@fn_bookmarks[fn]} \\f \\h"
|
73
|
+
out.span **{style: "mso-element:field-separator"}
|
74
|
+
out.span **{class: "MsoFootnoteReference"} do |s|
|
75
|
+
s << fn
|
76
|
+
end
|
77
|
+
out.span **{style: "mso-element:field-end"}
|
78
|
+
end
|
79
|
+
|
62
80
|
def footnote_parse(node, out)
|
63
81
|
return table_footnote_parse(node, out) if @in_table || @in_figure
|
64
82
|
fn = node["reference"]
|
65
|
-
|
66
|
-
|
83
|
+
return seen_footnote_parse(node, out, fn) if @seen_footnote.include?(fn)
|
84
|
+
@fn_bookmarks[fn] = bookmarkid
|
85
|
+
out.span **{style: "mso-bookmark:_Ref#{@fn_bookmarks[fn]}"} do |s|
|
86
|
+
s.a **{ "epub:type": "footnote", href: "#ftn#{fn}" } do |a|
|
87
|
+
a.sup { |sup| sup << fn }
|
88
|
+
end
|
67
89
|
end
|
68
|
-
return if @seen_footnote.include?(fn)
|
69
90
|
@in_footnote = true
|
70
91
|
@footnotes << make_generic_footnote_text(node, fn)
|
71
92
|
@in_footnote = false
|
@@ -51,8 +51,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
51
51
|
def word_admonition_images(docxml)
|
52
52
|
docxml.xpath("//div[@class = 'Admonition']//img").each do |i|
|
53
53
|
i["width"], i["height"] =
|
54
|
-
Html2Doc.image_resize(i,
|
55
|
-
@maxheight, 300)
|
54
|
+
Html2Doc.image_resize(i, image_localfile(i), @maxheight, 300)
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
@@ -70,17 +69,18 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
70
69
|
end
|
71
70
|
|
72
71
|
def style_update(node, css)
|
72
|
+
return unless node
|
73
73
|
node["style"] = node["style"] ? node["style"].sub(/;?$/, ";#{css}") : css
|
74
74
|
end
|
75
75
|
|
76
76
|
def word_image_caption(docxml)
|
77
77
|
docxml.xpath("//p[@class = 'FigureTitle' or @class = 'SourceTitle']").
|
78
78
|
each do |t|
|
79
|
-
if t
|
79
|
+
if t&.previous_element&.name == "img"
|
80
80
|
img = t.previous_element
|
81
81
|
t.previous_element.swap("<p class=\'figure\'>#{img.to_xml}</p>")
|
82
82
|
end
|
83
|
-
style_update(t
|
83
|
+
style_update(t&.previous_element, "page-break-after:avoid;")
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
@@ -177,10 +177,6 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
177
177
|
meta = @meta.get
|
178
178
|
meta[:filename] = filename
|
179
179
|
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
180
|
-
#headerfile = "header.html"
|
181
|
-
#File.open(headerfile, "w:UTF-8") { |f| f.write(template.render(params)) }
|
182
|
-
#@files_to_delete << headerfile
|
183
|
-
#headerfile
|
184
180
|
Tempfile.open(%w(header html), :encoding => "utf-8") do |f|
|
185
181
|
f.write(template.render(params))
|
186
182
|
f
|
@@ -188,7 +184,7 @@ xmlns:m="http://schemas.microsoft.com/office/2004/12/omml">
|
|
188
184
|
end
|
189
185
|
|
190
186
|
def word_toc_entry(toclevel, heading)
|
191
|
-
bookmark = Random.rand(1000000000)
|
187
|
+
bookmark = bookmarkid # Random.rand(1000000000)
|
192
188
|
<<~TOC
|
193
189
|
<p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span
|
194
190
|
lang="EN-GB" style='mso-no-proof:yes'>
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -240,7 +240,7 @@ INPUT
|
|
240
240
|
</dl>
|
241
241
|
</figure>
|
242
242
|
<figure id="figure-B">
|
243
|
-
<pre>A <
|
243
|
+
<pre alt="A B">A <
|
244
244
|
B</pre>
|
245
245
|
</figure>
|
246
246
|
<figure id="figure-C" unnumbered="true">
|
@@ -351,6 +351,9 @@ B</pre>
|
|
351
351
|
<example id="samplecode">
|
352
352
|
<name>Title</name>
|
353
353
|
<p>Hello</p>
|
354
|
+
<sourcecode id="X">
|
355
|
+
<name>Sample</name>
|
356
|
+
</sourcecode>
|
354
357
|
</example>
|
355
358
|
</foreword></preface>
|
356
359
|
</iso-standard>
|
@@ -362,6 +365,13 @@ B</pre>
|
|
362
365
|
<div id="samplecode" class="example">
|
363
366
|
<p class="example-title">EXAMPLE — Title</p>
|
364
367
|
<p>Hello</p>
|
368
|
+
<pre id='X' class='prettyprint '>
|
369
|
+
<br/>
|
370
|
+
 
|
371
|
+
<br/>
|
372
|
+
 
|
373
|
+
<p class='SourceTitle' style='text-align:center;'>Sample</p>
|
374
|
+
</pre>
|
365
375
|
</div>
|
366
376
|
</div>
|
367
377
|
<p class="zzSTDTitle1"/>
|
@@ -428,7 +438,7 @@ B</pre>
|
|
428
438
|
<br/>
|
429
439
|
<div>
|
430
440
|
<h1 class="ForewordTitle">Foreword</h1>
|
431
|
-
<pre id="samplecode" class="prettyprint lang-rb"><br/>    <br/>  puts x<br/><p class="SourceTitle" style="text-align:center;">Ruby <i>code</i></p></pre>
|
441
|
+
<pre id="samplecode" class="prettyprint lang-rb"><br/>    <br/>  puts x<br/><p class="SourceTitle" style="text-align:center;">Figure 1 — Ruby <i>code</i></p></pre>
|
432
442
|
</div>
|
433
443
|
<p class="zzSTDTitle1"/>
|
434
444
|
</div>
|
@@ -463,7 +473,7 @@ B</pre>
|
|
463
473
|
</p>
|
464
474
|
<div>
|
465
475
|
<h1 class="ForewordTitle">Foreword</h1>
|
466
|
-
<p id="samplecode" class="Sourcecode"><br/>    <br/>  puts x<br/></p><p class="SourceTitle" style="text-align:center;">Ruby <i>code</i></p>
|
476
|
+
<p id="samplecode" class="Sourcecode"><br/>    <br/>  puts x<br/></p><p class="SourceTitle" style="text-align:center;">Figure 1 — Ruby <i>code</i></p>
|
467
477
|
</div>
|
468
478
|
<p> </p>
|
469
479
|
</div>
|
@@ -493,7 +503,7 @@ B</pre>
|
|
493
503
|
<br/>
|
494
504
|
<div>
|
495
505
|
<h1 class="ForewordTitle">Foreword</h1>
|
496
|
-
<pre id="samplecode" class="prettyprint "><br/>    <br/>  <xml><br/><p class="SourceTitle" style="text-align:center;">XML code</p></pre>
|
506
|
+
<pre id="samplecode" class="prettyprint "><br/>    <br/>  <xml><br/><p class="SourceTitle" style="text-align:center;">Figure 1 — XML code</p></pre>
|
497
507
|
</div>
|
498
508
|
<p class="zzSTDTitle1"/>
|
499
509
|
</div>
|
@@ -1027,7 +1037,7 @@ INPUT
|
|
1027
1037
|
<h1 class="ForewordTitle">Foreword</h1>
|
1028
1038
|
<div id="_" class="pseudocode"><p id="_">  <b>A</b><br/>
|
1029
1039
|
        <span style="font-variant:small-caps;">B</span></p>
|
1030
|
-
<p id="_">  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
|
1040
|
+
<p id="_">  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Figure 1 — Label</p></div>
|
1031
1041
|
</div>
|
1032
1042
|
<p class="zzSTDTitle1"/>
|
1033
1043
|
</div>
|
@@ -1052,7 +1062,7 @@ INPUT
|
|
1052
1062
|
expect(xmlpp( File.read("test.doc").gsub(%r{^.*<h1 class="ForewordTitle">Foreword</h1>}m, "").gsub(%r{</div>.*}m, "</div>"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1053
1063
|
<div class="pseudocode"><a name="_" id="_"></a><p class="pseudocode"><a name="_" id="_"></a>  <b>A</b><br/>
|
1054
1064
|
        <span style="font-variant:small-caps;">B</span></p>
|
1055
|
-
<p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Label</p></div>
|
1065
|
+
<p class="pseudocode" style="page-break-after:avoid;"><a name="_" id="_"></a>  <i>C</i></p><p class="SourceTitle" style="text-align:center;">Figure 1 — Label</p></div>
|
1056
1066
|
OUTPUT
|
1057
1067
|
end
|
1058
1068
|
|
@@ -42,7 +42,7 @@ RSpec.describe IsoDoc do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
it "processes IsoXML footnotes (Word)" do
|
45
|
-
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
45
|
+
expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).gsub(/_Ref\d+/, "_Ref"))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
46
46
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
47
47
|
<preface>
|
48
48
|
<foreword>
|
@@ -59,38 +59,65 @@ RSpec.describe IsoDoc do
|
|
59
59
|
</preface>
|
60
60
|
</iso-standard>
|
61
61
|
INPUT
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
62
|
+
<html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
|
63
|
+
<head>
|
64
|
+
<style>
|
65
|
+
</style>
|
66
|
+
</head>
|
67
|
+
<body lang='EN-US' link='blue' vlink='#954F72'>
|
68
|
+
<div class='WordSection1'>
|
69
|
+
<p> </p>
|
70
|
+
</div>
|
71
|
+
<p>
|
72
|
+
<br clear='all' class='section'/>
|
73
|
+
</p>
|
74
|
+
<div class='WordSection2'>
|
75
|
+
<p>
|
76
|
+
<br clear='all' style='mso-special-character:line-break;page-break-before:always'/>
|
77
|
+
</p>
|
78
|
+
<div>
|
79
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
80
|
+
<p>
|
81
|
+
A.
|
82
|
+
<span style='mso-bookmark:_Ref'>
|
83
|
+
<a href='#ftn2' epub:type='footnote'>
|
84
|
+
<sup>2</sup>
|
85
|
+
</a>
|
86
|
+
</span>
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
B.
|
90
|
+
<span style='mso-element:field-begin'/>
|
91
|
+
NOTEREF _Ref \\f \\h
|
92
|
+
<span style='mso-element:field-separator'/>
|
93
|
+
<span class='MsoFootnoteReference'>2</span>
|
94
|
+
<span style='mso-element:field-end'/>
|
95
|
+
</p>
|
96
|
+
<p>
|
97
|
+
C.
|
98
|
+
<span style='mso-bookmark:_Ref'>
|
99
|
+
<a href='#ftn1' epub:type='footnote'>
|
100
|
+
<sup>1</sup>
|
101
|
+
</a>
|
102
|
+
</span>
|
103
|
+
</p>
|
104
|
+
</div>
|
105
|
+
<p> </p>
|
106
|
+
</div>
|
107
|
+
<p>
|
108
|
+
<br clear='all' class='section'/>
|
109
|
+
</p>
|
110
|
+
<div class='WordSection3'>
|
111
|
+
<p class='zzSTDTitle1'/>
|
112
|
+
<aside id='ftn2'>
|
113
|
+
<p id='_1e228e29-baef-4f38-b048-b05a051747e4'>Formerly denoted as 15 % (m/m).</p>
|
114
|
+
</aside>
|
115
|
+
<aside id='ftn1'>
|
116
|
+
<p id='_1e228e29-baef-4f38-b048-b05a051747e4'>Hello! denoted as 15 % (m/m).</p>
|
117
|
+
</aside>
|
118
|
+
</div>
|
119
|
+
</body>
|
120
|
+
</html>
|
94
121
|
OUTPUT
|
95
122
|
end
|
96
123
|
|
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -31,6 +31,28 @@ RSpec.describe IsoDoc do
|
|
31
31
|
OUTPUT
|
32
32
|
end
|
33
33
|
|
34
|
+
it "ignores index entries" do
|
35
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
36
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
37
|
+
<preface><foreword>
|
38
|
+
<p><index primary="A" secondary="B" tertiary="C"/></p>
|
39
|
+
</foreword></preface>
|
40
|
+
<sections>
|
41
|
+
</iso-standard>
|
42
|
+
INPUT
|
43
|
+
#{HTML_HDR}
|
44
|
+
<br/>
|
45
|
+
<div>
|
46
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
47
|
+
<p/>
|
48
|
+
</div>
|
49
|
+
<p class='zzSTDTitle1'/>
|
50
|
+
</div>
|
51
|
+
</body>
|
52
|
+
</html>
|
53
|
+
OUTPUT
|
54
|
+
end
|
55
|
+
|
34
56
|
it "processes embedded inline formatting" do
|
35
57
|
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
36
58
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
@@ -57,6 +79,31 @@ RSpec.describe IsoDoc do
|
|
57
79
|
OUTPUT
|
58
80
|
end
|
59
81
|
|
82
|
+
it "processes inline images" do
|
83
|
+
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
84
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
85
|
+
<preface><foreword>
|
86
|
+
<p>
|
87
|
+
<image src="rice_images/rice_image1.png" height="20" width="30" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png" alt="alttext" title="titletxt"/>
|
88
|
+
</p>
|
89
|
+
</foreword></preface>
|
90
|
+
</iso-standard>
|
91
|
+
INPUT
|
92
|
+
#{HTML_HDR}
|
93
|
+
<br/>
|
94
|
+
<div>
|
95
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
96
|
+
<p>
|
97
|
+
<img src='rice_images/rice_image1.png' height='20' width='30' title='titletxt' alt='alttext'/>
|
98
|
+
</p>
|
99
|
+
</div>
|
100
|
+
<p class='zzSTDTitle1'/>
|
101
|
+
</div>
|
102
|
+
</body>
|
103
|
+
</html>
|
104
|
+
OUTPUT
|
105
|
+
end
|
106
|
+
|
60
107
|
it "processes links" do
|
61
108
|
expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
62
109
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
@@ -925,7 +925,7 @@ TOCLEVEL
|
|
925
925
|
<br />
|
926
926
|
<div>
|
927
927
|
<h1 class="ForewordTitle">Foreword</h1>
|
928
|
-
<pre id="samplecode" class="prettyprint "><br />    <br />  <xml> &<br /><p class="SourceTitle" style="text-align:center;">XML code</p></pre>
|
928
|
+
<pre id="samplecode" class="prettyprint "><br />    <br />  <xml> &<br /><p class="SourceTitle" style="text-align:center;">Figure 1 — XML code</p></pre>
|
929
929
|
</div>
|
930
930
|
<p class="zzSTDTitle1"></p>
|
931
931
|
</main>
|
@@ -955,7 +955,7 @@ TOCLEVEL
|
|
955
955
|
</p>
|
956
956
|
<div>
|
957
957
|
<h1 class="ForewordTitle">Foreword</h1>
|
958
|
-
<p class="Sourcecode" style="page-break-after:avoid;"><a name="samplecode" id="samplecode"></a><br/>    <br/>  <xml> &<br/></p><p class="SourceTitle" style="text-align:center;">XML code</p>
|
958
|
+
<p class="Sourcecode" style="page-break-after:avoid;"><a name="samplecode" id="samplecode"></a><br/>    <br/>  <xml> &<br/></p><p class="SourceTitle" style="text-align:center;">Figure 1 — XML code</p>
|
959
959
|
</div>
|
960
960
|
<p class="MsoNormal"> </p>
|
961
961
|
</div>
|
data/spec/isodoc/xref_spec.rb
CHANGED
@@ -203,10 +203,13 @@ RSpec.describe IsoDoc do
|
|
203
203
|
<xref target="N"/>
|
204
204
|
<xref target="note1"/>
|
205
205
|
<xref target="note3"/>
|
206
|
+
<xref target="note4"/>
|
206
207
|
<xref target="note2"/>
|
208
|
+
<xref target="note51"/>
|
207
209
|
<xref target="AN"/>
|
208
210
|
<xref target="Anote1"/>
|
209
211
|
<xref target="Anote2"/>
|
212
|
+
<xref target="Anote3"/>
|
210
213
|
</p>
|
211
214
|
</foreword>
|
212
215
|
<introduction id="intro">
|
@@ -240,6 +243,14 @@ RSpec.describe IsoDoc do
|
|
240
243
|
<figure id="note3" class="pseudocode">
|
241
244
|
<p>pseudocode</p>
|
242
245
|
</figure>
|
246
|
+
<sourcecode id="note4"><name>Source! Code!</name>
|
247
|
+
A B C
|
248
|
+
</sourcecode>
|
249
|
+
<example id="note5">
|
250
|
+
<sourcecode id="note51">
|
251
|
+
A B C
|
252
|
+
</sourcecode>
|
253
|
+
</example>
|
243
254
|
<figure id="note2">
|
244
255
|
<name>Split-it-right sample divider</name>
|
245
256
|
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
@@ -264,6 +275,9 @@ RSpec.describe IsoDoc do
|
|
264
275
|
<name>Split-it-right sample divider</name>
|
265
276
|
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
266
277
|
</figure>
|
278
|
+
<sourcecode id="Anote3"><name>Source! Code!</name>
|
279
|
+
A B C
|
280
|
+
</sourcecode>
|
267
281
|
</clause>
|
268
282
|
</annex>
|
269
283
|
</iso-standard>
|
@@ -277,11 +291,14 @@ RSpec.describe IsoDoc do
|
|
277
291
|
<a href="#N2">Figure (??)</a>
|
278
292
|
<a href="#N">Figure 2</a>
|
279
293
|
<a href="#note1">Figure 3</a>
|
280
|
-
<a href="#note3">
|
281
|
-
<a href="#
|
294
|
+
<a href="#note3">Figure 4</a>
|
295
|
+
<a href="#note4">Figure 5</a>
|
296
|
+
<a href="#note2">Figure 6</a>
|
297
|
+
<a href="#note51">[note51]</a>
|
282
298
|
<a href="#AN">Figure A.1</a>
|
283
299
|
<a href="#Anote1">Figure (??)</a>
|
284
300
|
<a href="#Anote2">Figure A.2</a>
|
301
|
+
<a href="#Anote3">Figure A.3</a>
|
285
302
|
</p>
|
286
303
|
</div>
|
287
304
|
<br/>
|
@@ -313,7 +330,7 @@ RSpec.describe IsoDoc do
|
|
313
330
|
</div>
|
314
331
|
<div id="widgets">
|
315
332
|
<h1>3.  Widgets</h1>
|
316
|
-
<div id="widgets1"><h2>3.1. 
|
333
|
+
<div id="widgets1"><h2>3.1.  </h2>
|
317
334
|
<div id="note1" class="figure">
|
318
335
|
|
319
336
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
@@ -321,22 +338,39 @@ RSpec.describe IsoDoc do
|
|
321
338
|
<div id="note3" class="pseudocode">
|
322
339
|
<p>pseudocode</p>
|
323
340
|
</div>
|
341
|
+
<pre id='note4' class='prettyprint '>
|
342
|
+
<br/>
|
343
|
+
  A B C
|
344
|
+
<br/>
|
345
|
+
 
|
346
|
+
<p class='SourceTitle' style='text-align:center;'>Figure 5 — Source! Code!</p>
|
347
|
+
</pre>
|
348
|
+
<div id='note5' class='example'>
|
349
|
+
<p class='example-title'>EXAMPLE</p>
|
350
|
+
<pre id='note51' class='prettyprint '>
|
351
|
+
<br/>
|
352
|
+
  A B C
|
353
|
+
<br/>
|
354
|
+
 
|
355
|
+
</pre>
|
356
|
+
</div>
|
357
|
+
|
324
358
|
<div id="note2" class="figure">
|
325
359
|
|
326
360
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
327
|
-
<p class="FigureTitle" style="text-align:center;">Figure
|
328
|
-
<p> <a href="#note1">Figure 3</a> <a href="#note2">Figure
|
361
|
+
<p class="FigureTitle" style="text-align:center;">Figure 6 — Split-it-right sample divider</p></div>
|
362
|
+
<p> <a href="#note1">Figure 3</a> <a href="#note2">Figure 6</a> </p>
|
329
363
|
</div>
|
330
364
|
</div>
|
331
365
|
<br/>
|
332
366
|
<div id="annex1" class="Section3">
|
333
|
-
<div id="annex1a"><h2>A.1. 
|
367
|
+
<div id="annex1a"><h2>A.1.  </h2>
|
334
368
|
<div id="AN" class="figure">
|
335
369
|
|
336
370
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
337
371
|
<p class="FigureTitle" style="text-align:center;">Figure A.1 — Split-it-right sample divider</p></div>
|
338
372
|
</div>
|
339
|
-
<div id="annex1b"><h2>A.2. 
|
373
|
+
<div id="annex1b"><h2>A.2.  </h2>
|
340
374
|
<div id="Anote1" class="figure">
|
341
375
|
|
342
376
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
@@ -345,7 +379,14 @@ RSpec.describe IsoDoc do
|
|
345
379
|
|
346
380
|
<img src="rice_images/rice_image1.png" height="auto" width="auto"/>
|
347
381
|
<p class="FigureTitle" style="text-align:center;">Figure A.2 — Split-it-right sample divider</p></div>
|
348
|
-
|
382
|
+
<pre id='Anote3' class='prettyprint '>
|
383
|
+
<br/>
|
384
|
+
  A B C
|
385
|
+
<br/>
|
386
|
+
 
|
387
|
+
<p class='SourceTitle' style='text-align:center;'>Figure A.3 — Source! Code!</p>
|
388
|
+
</pre>
|
389
|
+
</div>
|
349
390
|
</div>
|
350
391
|
</div>
|
351
392
|
</body>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isodoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciimath
|