isodoc 0.7.1 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +8 -6
- data/README.adoc +3 -3
- data/lib/{isodoc → isodoc-yaml}/i18n-en.yaml +0 -0
- data/lib/{isodoc → isodoc-yaml}/i18n-fr.yaml +0 -0
- data/lib/{isodoc → isodoc-yaml}/i18n-zh-Hans.yaml +0 -0
- data/lib/isodoc.rb +13 -6
- data/lib/isodoc/class_utils.rb +24 -0
- data/lib/isodoc/common.rb +34 -0
- data/lib/isodoc/convert.rb +3 -16
- data/lib/isodoc/function.rb +4 -0
- data/lib/isodoc/{blocks.rb → function/blocks.rb} +2 -2
- data/lib/isodoc/{cleanup.rb → function/cleanup.rb} +4 -9
- data/lib/isodoc/{i18n.rb → function/i18n.rb} +13 -10
- data/lib/isodoc/{inline.rb → function/inline.rb} +2 -4
- data/lib/isodoc/{lists.rb → function/lists.rb} +5 -4
- data/lib/isodoc/{references.rb → function/references.rb} +4 -3
- data/lib/isodoc/{section.rb → function/section.rb} +4 -3
- data/lib/isodoc/{table.rb → function/table.rb} +3 -2
- data/lib/isodoc/{terms.rb → function/terms.rb} +3 -2
- data/lib/isodoc/{iso2wordhtml.rb → function/to_word_html.rb} +2 -3
- data/lib/isodoc/{utils.rb → function/utils.rb} +6 -22
- data/lib/isodoc/{xref_gen.rb → function/xref_gen.rb} +4 -3
- data/lib/isodoc/{xref_sect_gen.rb → function/xref_sect_gen.rb} +4 -3
- data/lib/isodoc/html_convert.rb +12 -0
- data/lib/isodoc/html_function.rb +4 -0
- data/lib/isodoc/{htmlconvert → html_function}/comments.rb +2 -3
- data/lib/isodoc/{htmlconvert → html_function}/footnotes.rb +3 -4
- data/lib/isodoc/{htmlconvert → html_function}/html.rb +5 -5
- data/lib/isodoc/iso/html/html_iso_titlepage.html +2 -2
- data/lib/isodoc/iso/{convert.rb → html_convert.rb} +1 -1
- data/lib/isodoc/iso/{wordconvert.rb → word_convert.rb} +0 -0
- data/lib/isodoc/metadata.rb +27 -12
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/{wordconvert/convert.rb → word_convert.rb} +9 -11
- data/lib/isodoc/word_function.rb +4 -0
- data/lib/isodoc/word_function/body.rb +149 -0
- data/lib/isodoc/{wordconvert → word_function}/comments.rb +2 -2
- data/lib/isodoc/word_function/footnotes.rb +81 -0
- data/lib/isodoc/word_function/postprocess.rb +116 -0
- data/spec/isodoc/blocks_spec.rb +17 -17
- data/spec/isodoc/cleanup_spec.rb +8 -8
- data/spec/isodoc/footnotes_spec.rb +2 -2
- data/spec/isodoc/i18n_spec.rb +4 -4
- data/spec/isodoc/inline_spec.rb +7 -7
- data/spec/isodoc/iso_spec.rb +5 -5
- data/spec/isodoc/lists_spec.rb +4 -4
- data/spec/isodoc/metadata_spec.rb +2 -2
- data/spec/isodoc/postproc_spec.rb +9 -9
- data/spec/isodoc/ref_spec.rb +3 -3
- data/spec/isodoc/section_spec.rb +6 -6
- data/spec/isodoc/table_spec.rb +1 -1
- data/spec/isodoc/terms_spec.rb +1 -1
- data/spec/isodoc/xref_spec.rb +11 -11
- metadata +35 -30
- data/lib/isodoc/htmlconvert/convert.rb +0 -13
- data/lib/isodoc/wordconvert/footnotes.rb +0 -81
- data/lib/isodoc/wordconvert/postprocess.rb +0 -115
- data/lib/isodoc/wordconvert/wordconvertmodule.rb +0 -150
@@ -0,0 +1,116 @@
|
|
1
|
+
module IsoDoc::WordFunction
|
2
|
+
module Postprocess
|
3
|
+
|
4
|
+
def postprocess(result, filename, dir)
|
5
|
+
header = generate_header(filename, dir)
|
6
|
+
result = from_xhtml(cleanup(to_xhtml(result)))
|
7
|
+
toWord(result, filename, dir, header)
|
8
|
+
@files_to_delete.each { |f| system "rm #{f}" }
|
9
|
+
end
|
10
|
+
|
11
|
+
def toWord(result, filename, dir, header)
|
12
|
+
result = populate_template(result, :word)
|
13
|
+
result = from_xhtml(word_cleanup(to_xhtml(result)))
|
14
|
+
Html2Doc.process(result, filename: filename, stylesheet: @wordstylesheet,
|
15
|
+
header_file: header, dir: dir,
|
16
|
+
asciimathdelims: [@openmathdelim, @closemathdelim],
|
17
|
+
liststyles: { ul: @ulstyle, ol: @olstyle })
|
18
|
+
end
|
19
|
+
|
20
|
+
def word_cleanup(docxml)
|
21
|
+
word_preface(docxml)
|
22
|
+
word_annex_cleanup(docxml)
|
23
|
+
docxml
|
24
|
+
end
|
25
|
+
|
26
|
+
# force Annex h2 to be p.h2Annex, so it is not picked up by ToC
|
27
|
+
def word_annex_cleanup(docxml)
|
28
|
+
docxml.xpath("//h2[ancestor::*[@class = 'Section3']]").each do |h2|
|
29
|
+
h2.name = "p"
|
30
|
+
h2["class"] = "h2Annex"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def word_preface(docxml)
|
35
|
+
word_cover(docxml) if @wordcoverpage
|
36
|
+
word_intro(docxml) if @wordintropage
|
37
|
+
end
|
38
|
+
|
39
|
+
def word_cover(docxml)
|
40
|
+
cover = File.read(@wordcoverpage, encoding: "UTF-8")
|
41
|
+
cover = populate_template(cover, :word)
|
42
|
+
coverxml = to_xhtml_fragment(cover)
|
43
|
+
docxml.at('//div[@class="WordSection1"]').children.first.previous =
|
44
|
+
coverxml.to_xml(encoding: "US-ASCII")
|
45
|
+
end
|
46
|
+
|
47
|
+
def word_intro(docxml)
|
48
|
+
intro = File.read(@wordintropage, encoding: "UTF-8").
|
49
|
+
sub(/WORDTOC/, make_WordToC(docxml))
|
50
|
+
intro = populate_template(intro, :word)
|
51
|
+
introxml = to_xhtml_fragment(intro)
|
52
|
+
docxml.at('//div[@class="WordSection2"]').children.first.previous =
|
53
|
+
introxml.to_xml(encoding: "US-ASCII")
|
54
|
+
end
|
55
|
+
|
56
|
+
def generate_header(filename, _dir)
|
57
|
+
return nil unless @header
|
58
|
+
template = Liquid::Template.parse(File.read(@header, encoding: "UTF-8"))
|
59
|
+
meta = @meta.get
|
60
|
+
meta[:filename] = filename
|
61
|
+
params = meta.map { |k, v| [k.to_s, v] }.to_h
|
62
|
+
File.open("header.html", "w") do |f|
|
63
|
+
f.write(template.render(params))
|
64
|
+
end
|
65
|
+
@files_to_delete << "header.html"
|
66
|
+
"header.html"
|
67
|
+
end
|
68
|
+
|
69
|
+
def word_toc_entry(toclevel, heading)
|
70
|
+
bookmark = Random.rand(1000000000)
|
71
|
+
<<~TOC
|
72
|
+
<p class="MsoToc#{toclevel}"><span class="MsoHyperlink"><span
|
73
|
+
lang="EN-GB" style='mso-no-proof:yes'>
|
74
|
+
<a href="#_Toc#{bookmark}">#{heading}<span lang="EN-GB"
|
75
|
+
class="MsoTocTextSpan">
|
76
|
+
<span style='mso-tab-count:1 dotted'>. </span>
|
77
|
+
</span><span lang="EN-GB" class="MsoTocTextSpan">
|
78
|
+
<span style='mso-element:field-begin'></span></span>
|
79
|
+
<span lang="EN-GB"
|
80
|
+
class="MsoTocTextSpan"> PAGEREF _Toc#{bookmark} \\h </span>
|
81
|
+
<span lang="EN-GB" class="MsoTocTextSpan"><span
|
82
|
+
style='mso-element:field-separator'></span></span><span
|
83
|
+
lang="EN-GB" class="MsoTocTextSpan">1</span>
|
84
|
+
<span lang="EN-GB"
|
85
|
+
class="MsoTocTextSpan"></span><span
|
86
|
+
lang="EN-GB" class="MsoTocTextSpan"><span
|
87
|
+
style='mso-element:field-end'></span></span></a></span></span></p>
|
88
|
+
|
89
|
+
TOC
|
90
|
+
end
|
91
|
+
|
92
|
+
WORD_TOC_PREFACE1 = <<~TOC.freeze
|
93
|
+
<span lang="EN-GB"><span
|
94
|
+
style='mso-element:field-begin'></span><span
|
95
|
+
style='mso-spacerun:yes'> </span>TOC
|
96
|
+
\\o "1-2" \\h \\z \\u <span
|
97
|
+
style='mso-element:field-separator'></span></span>
|
98
|
+
TOC
|
99
|
+
|
100
|
+
WORD_TOC_SUFFIX1 = <<~TOC.freeze
|
101
|
+
<p class="MsoToc1"><span lang="EN-GB"><span
|
102
|
+
style='mso-element:field-end'></span></span><span
|
103
|
+
lang="EN-GB"><o:p> </o:p></span></p>
|
104
|
+
TOC
|
105
|
+
|
106
|
+
def make_WordToC(docxml)
|
107
|
+
toc = ""
|
108
|
+
docxml.xpath("//h1 | //h2[not(ancestor::*[@class = 'Section3'])]").
|
109
|
+
each do |h|
|
110
|
+
toc += word_toc_entry(h.name == "h1" ? 1 : 2, header_strip(h))
|
111
|
+
end
|
112
|
+
toc.sub(/(<p class="MsoToc1">)/,
|
113
|
+
%{\\1#{WORD_TOC_PREFACE1}}) + WORD_TOC_SUFFIX1
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/spec/isodoc/blocks_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes unlabelled notes" do
|
5
|
-
expect(IsoDoc::
|
5
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<preface><foreword>
|
8
8
|
<note>
|
@@ -27,7 +27,7 @@ RSpec.describe IsoDoc do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "processes labelled notes" do
|
30
|
-
expect(IsoDoc::
|
30
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
31
31
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
32
32
|
<preface><foreword>
|
33
33
|
<note id="note1">
|
@@ -52,7 +52,7 @@ INPUT
|
|
52
52
|
end
|
53
53
|
|
54
54
|
it "processes sequences of notes" do
|
55
|
-
expect(IsoDoc::
|
55
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
56
56
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
57
57
|
<preface><foreword>
|
58
58
|
<note id="note1">
|
@@ -83,7 +83,7 @@ INPUT
|
|
83
83
|
end
|
84
84
|
|
85
85
|
it "processes multi-para notes" do
|
86
|
-
expect(IsoDoc::
|
86
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
87
87
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
88
88
|
<preface><foreword>
|
89
89
|
<note>
|
@@ -110,7 +110,7 @@ INPUT
|
|
110
110
|
end
|
111
111
|
|
112
112
|
it "processes non-para notes" do
|
113
|
-
expect(IsoDoc::
|
113
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
114
114
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
115
115
|
<preface><foreword>
|
116
116
|
<note>
|
@@ -143,7 +143,7 @@ INPUT
|
|
143
143
|
end
|
144
144
|
|
145
145
|
it "processes figures" do
|
146
|
-
expect(strip_guid(IsoDoc::
|
146
|
+
expect(strip_guid(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
|
147
147
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
148
148
|
<preface><foreword>
|
149
149
|
<figure id="figureA-1">
|
@@ -180,7 +180,7 @@ INPUT
|
|
180
180
|
OUTPUT
|
181
181
|
end
|
182
182
|
|
183
|
-
|
183
|
+
it "processes figures (Word)" do
|
184
184
|
expect(strip_guid(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to <<~"OUTPUT"
|
185
185
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
186
186
|
<preface><foreword>
|
@@ -232,7 +232,7 @@ INPUT
|
|
232
232
|
end
|
233
233
|
|
234
234
|
it "processes examples" do
|
235
|
-
expect(IsoDoc::
|
235
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
236
236
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
237
237
|
<preface><foreword>
|
238
238
|
<example id="samplecode">
|
@@ -263,7 +263,7 @@ INPUT
|
|
263
263
|
|
264
264
|
|
265
265
|
it "processes sequences of examples" do
|
266
|
-
expect(IsoDoc::
|
266
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
267
267
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
268
268
|
<preface><foreword>
|
269
269
|
<example id="samplecode">
|
@@ -304,7 +304,7 @@ INPUT
|
|
304
304
|
end
|
305
305
|
|
306
306
|
it "processes sourcecode" do
|
307
|
-
expect(IsoDoc::
|
307
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
308
308
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
309
309
|
<preface><foreword>
|
310
310
|
<sourcecode id="samplecode">
|
@@ -328,7 +328,7 @@ INPUT
|
|
328
328
|
end
|
329
329
|
|
330
330
|
it "processes sourcecode with escapes preserved" do
|
331
|
-
expect(IsoDoc::
|
331
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
332
332
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
333
333
|
<preface><foreword>
|
334
334
|
<sourcecode id="samplecode">
|
@@ -352,7 +352,7 @@ INPUT
|
|
352
352
|
end
|
353
353
|
|
354
354
|
it "processes sourcecode with annotations" do
|
355
|
-
expect(IsoDoc::
|
355
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
356
356
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
357
357
|
<preface><foreword>
|
358
358
|
<sourcecode id="_">puts "Hello, world." <callout target="A">1</callout>
|
@@ -384,7 +384,7 @@ INPUT
|
|
384
384
|
end
|
385
385
|
|
386
386
|
it "processes admonitions" do
|
387
|
-
expect(IsoDoc::
|
387
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
388
388
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
389
389
|
<preface><foreword>
|
390
390
|
<admonition id="_70234f78-64e5-4dfc-8b6f-f3f037348b6a" type="caution">
|
@@ -409,7 +409,7 @@ INPUT
|
|
409
409
|
end
|
410
410
|
|
411
411
|
it "processes formulae" do
|
412
|
-
expect(IsoDoc::
|
412
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
413
413
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
414
414
|
<preface><foreword>
|
415
415
|
<formula id="_be9158af-7e93-4ee2-90c5-26d31c181934">
|
@@ -448,7 +448,7 @@ INPUT
|
|
448
448
|
end
|
449
449
|
|
450
450
|
it "processes paragraph alignments" do
|
451
|
-
expect(IsoDoc::
|
451
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
452
452
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
453
453
|
<preface><foreword>
|
454
454
|
<p align="left" id="_08bfe952-d57f-4150-9c95-5d52098cc2a8">Vache Equipment<br/>
|
@@ -519,7 +519,7 @@ World</p>
|
|
519
519
|
|
520
520
|
|
521
521
|
it "processes blockquotes" do
|
522
|
-
expect(IsoDoc::
|
522
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
523
523
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
524
524
|
<preface><foreword>
|
525
525
|
<quote id="_044bd364-c832-4b78-8fea-92242402a1d1">
|
@@ -549,7 +549,7 @@ World</p>
|
|
549
549
|
end
|
550
550
|
|
551
551
|
it "processes term domains" do
|
552
|
-
expect(IsoDoc::
|
552
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
553
553
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
554
554
|
<sections>
|
555
555
|
<terms>
|
data/spec/isodoc/cleanup_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "nokogiri"
|
|
3
3
|
|
4
4
|
RSpec.describe IsoDoc do
|
5
5
|
it "cleans up admonitions" do
|
6
|
-
expect(IsoDoc::
|
6
|
+
expect(IsoDoc::WordConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
7
7
|
<html>
|
8
8
|
<body>
|
9
9
|
<div class="Admonition">
|
@@ -26,7 +26,7 @@ RSpec.describe IsoDoc do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "cleans up figures" do
|
29
|
-
expect(IsoDoc::
|
29
|
+
expect(IsoDoc::HtmlConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
30
30
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
31
31
|
<body>
|
32
32
|
<div class="figure">
|
@@ -80,7 +80,7 @@ RSpec.describe IsoDoc do
|
|
80
80
|
end
|
81
81
|
|
82
82
|
it "cleans up inline headers" do
|
83
|
-
expect(IsoDoc::
|
83
|
+
expect(IsoDoc::WordConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
84
84
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
85
85
|
<head>
|
86
86
|
<title>test</title>
|
@@ -149,7 +149,7 @@ RSpec.describe IsoDoc do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
it "cleans up footnotes" do
|
152
|
-
expect(IsoDoc::
|
152
|
+
expect(IsoDoc::HtmlConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
153
153
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
154
154
|
<head>
|
155
155
|
<title>test</title>
|
@@ -218,7 +218,7 @@ RSpec.describe IsoDoc do
|
|
218
218
|
end
|
219
219
|
|
220
220
|
it "cleans up tables with tfoot" do
|
221
|
-
expect(IsoDoc::
|
221
|
+
expect(IsoDoc::HtmlConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
222
222
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
223
223
|
<head>
|
224
224
|
<title>test</title>
|
@@ -505,7 +505,7 @@ INPUT
|
|
505
505
|
<td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">2,26</td>
|
506
506
|
<td align="center" style="border-top:solid windowtext 1.5pt;border-bottom:0pt;">6,06</td>
|
507
507
|
</tr>
|
508
|
-
<tr><td colspan="5" style="border-top:0pt;mso-border-top-alt:0pt;
|
508
|
+
<tr><td colspan="5" style="border-top:0pt;mso-border-top-alt:0pt;border-bottom:solid windowtext 1.5pt;mso-border-bottom-alt:solid windowtext 1.5pt;"><div id="" class="Note">
|
509
509
|
<p class="Note">NOTE<span style="mso-tab-count:1">  </span>This is a table about rice</p>
|
510
510
|
</div><div class="TableFootnote"><div id="ftntableD-1a">
|
511
511
|
<p id="_0fe65e9a-5531-408e-8295-eeff35f41a55" class="TableFootnote"><a id="tableD-1a" class="TableFootnoteRef">a<span style="mso-tab-count:1">  </span></a>Parboiled rice.</p>
|
@@ -533,7 +533,7 @@ INPUT
|
|
533
533
|
|
534
534
|
|
535
535
|
it "cleans up tables without tfoot" do
|
536
|
-
expect(IsoDoc::
|
536
|
+
expect(IsoDoc::HtmlConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
537
537
|
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
538
538
|
<head>
|
539
539
|
<title>test</title>
|
@@ -672,7 +672,7 @@ INPUT
|
|
672
672
|
end
|
673
673
|
|
674
674
|
it "cleans up symbols lists" do
|
675
|
-
expect(IsoDoc::
|
675
|
+
expect(IsoDoc::WordConvert.new({}).cleanup(Nokogiri::XML(<<~"INPUT")).to_s).to be_equivalent_to <<~"OUTPUT"
|
676
676
|
<div id="L" class="Symbols">
|
677
677
|
<h1>4.<span style="mso-tab-count:1">  </span>Symbols and Abbreviated Terms</h1>
|
678
678
|
<dl>
|
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes IsoXML footnotes" do
|
5
|
-
expect(IsoDoc::
|
5
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<preface>
|
8
8
|
<foreword>
|
@@ -94,7 +94,7 @@ RSpec.describe IsoDoc do
|
|
94
94
|
|
95
95
|
it "processes IsoXML reviewer notes" do
|
96
96
|
system "rm -f test.html"
|
97
|
-
IsoDoc::
|
97
|
+
IsoDoc::HtmlConvert.new({wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.css"}).convert("test", <<~"INPUT", false)
|
98
98
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
99
99
|
<preface>
|
100
100
|
<foreword>
|
data/spec/isodoc/i18n_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes English" do
|
5
|
-
expect(IsoDoc::
|
5
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<bibdata>
|
8
8
|
<language>en</language>
|
@@ -159,7 +159,7 @@ RSpec.describe IsoDoc do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
it "defaults to English" do
|
162
|
-
expect(IsoDoc::
|
162
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
163
163
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
164
164
|
<bibdata>
|
165
165
|
<language>tlh</language>
|
@@ -316,7 +316,7 @@ RSpec.describe IsoDoc do
|
|
316
316
|
end
|
317
317
|
|
318
318
|
it "processes French" do
|
319
|
-
expect(IsoDoc::
|
319
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
320
320
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
321
321
|
<bibdata>
|
322
322
|
<language>fr</language>
|
@@ -472,7 +472,7 @@ RSpec.describe IsoDoc do
|
|
472
472
|
end
|
473
473
|
|
474
474
|
it "processes Simplified Chinese" do
|
475
|
-
expect(IsoDoc::
|
475
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
476
476
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
477
477
|
<bibdata>
|
478
478
|
<language>zh</language>
|
data/spec/isodoc/inline_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
|
|
2
2
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
it "processes inline formatting" do
|
5
|
-
expect(IsoDoc::
|
5
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
6
6
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
7
|
<preface><foreword>
|
8
8
|
<p>
|
@@ -32,7 +32,7 @@ RSpec.describe IsoDoc do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
it "processes links" do
|
35
|
-
expect(IsoDoc::
|
35
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
36
36
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
37
37
|
<preface><foreword>
|
38
38
|
<p>
|
@@ -60,7 +60,7 @@ RSpec.describe IsoDoc do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "processes unrecognised markup" do
|
63
|
-
expect(IsoDoc::
|
63
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
64
64
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
65
65
|
<preface><foreword>
|
66
66
|
<p>
|
@@ -86,7 +86,7 @@ RSpec.describe IsoDoc do
|
|
86
86
|
end
|
87
87
|
|
88
88
|
it "processes AsciiMath and MathML" do
|
89
|
-
expect(IsoDoc::
|
89
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
90
90
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
91
91
|
<preface><foreword>
|
92
92
|
<p>
|
@@ -118,7 +118,7 @@ RSpec.describe IsoDoc do
|
|
118
118
|
end
|
119
119
|
|
120
120
|
it "overrides AsciiMath delimiters" do
|
121
|
-
expect(IsoDoc::
|
121
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
122
122
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
123
123
|
<preface><foreword>
|
124
124
|
<p>
|
@@ -146,7 +146,7 @@ RSpec.describe IsoDoc do
|
|
146
146
|
end
|
147
147
|
|
148
148
|
it "processes eref types" do
|
149
|
-
expect(IsoDoc::
|
149
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
150
150
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
151
151
|
<preface><foreword>
|
152
152
|
<p>
|
@@ -191,7 +191,7 @@ RSpec.describe IsoDoc do
|
|
191
191
|
end
|
192
192
|
|
193
193
|
it "processes eref content" do
|
194
|
-
expect(IsoDoc::
|
194
|
+
expect(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
195
195
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
196
196
|
<preface><foreword>
|
197
197
|
<p>
|
data/spec/isodoc/iso_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
RSpec.describe IsoDoc do
|
4
4
|
system "rm -f test.html"
|
5
5
|
it "processes isodoc as ISO: HTML output" do
|
6
|
-
IsoDoc::Iso::
|
6
|
+
IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", false)
|
7
7
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
8
8
|
<preface><foreword>
|
9
9
|
<note>
|
@@ -20,7 +20,7 @@ RSpec.describe IsoDoc do
|
|
20
20
|
|
21
21
|
it "processes isodoc as ISO: alt HTML output" do
|
22
22
|
system "rm -f test.html"
|
23
|
-
IsoDoc::Iso::
|
23
|
+
IsoDoc::Iso::HtmlConvert.new({alt: true}).convert("test", <<~"INPUT", false)
|
24
24
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
25
25
|
<preface><foreword>
|
26
26
|
<note>
|
@@ -37,7 +37,7 @@ RSpec.describe IsoDoc do
|
|
37
37
|
|
38
38
|
it "processes isodoc as ISO: Chinese HTML output" do
|
39
39
|
system "rm -f test.html"
|
40
|
-
IsoDoc::Iso::
|
40
|
+
IsoDoc::Iso::HtmlConvert.new({script: "Hans"}).convert("test", <<~"INPUT", false)
|
41
41
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
42
42
|
<preface><foreword>
|
43
43
|
<note>
|
@@ -54,7 +54,7 @@ RSpec.describe IsoDoc do
|
|
54
54
|
|
55
55
|
it "processes isodoc as ISO: user nominated fonts" do
|
56
56
|
system "rm -f test.html"
|
57
|
-
IsoDoc::Iso::
|
57
|
+
IsoDoc::Iso::HtmlConvert.new({bodyfont: "Zapf Chancery", headerfont: "Comic Sans", monospacefont: "Andale Mono"}).convert("test", <<~"INPUT", false)
|
58
58
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
59
59
|
<preface><foreword>
|
60
60
|
<note>
|
@@ -87,7 +87,7 @@ RSpec.describe IsoDoc do
|
|
87
87
|
end
|
88
88
|
|
89
89
|
it "does not include IEV in references" do
|
90
|
-
expect(IsoDoc::Iso::
|
90
|
+
expect(IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)).to be_equivalent_to <<~"OUTPUT"
|
91
91
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
92
92
|
<preface><foreword>
|
93
93
|
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">
|