isodoc 1.6.1 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rake.yml +2 -12
- data/.hound.yml +3 -1
- data/.rubocop.yml +4 -8
- data/Rakefile +2 -2
- data/isodoc.gemspec +4 -3
- data/lib/isodoc-yaml/i18n-ar.yaml +152 -0
- data/lib/isodoc-yaml/i18n-de.yaml +149 -0
- data/lib/isodoc-yaml/i18n-en.yaml +1 -0
- data/lib/isodoc-yaml/i18n-es.yaml +151 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +1 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +154 -0
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +1 -0
- data/lib/isodoc.rb +0 -2
- data/lib/isodoc/common.rb +2 -0
- data/lib/isodoc/convert.rb +8 -2
- data/lib/isodoc/function/blocks.rb +15 -4
- data/lib/isodoc/function/cleanup.rb +52 -43
- data/lib/isodoc/function/form.rb +51 -0
- data/lib/isodoc/function/inline.rb +8 -7
- data/lib/isodoc/function/references.rb +71 -77
- data/lib/isodoc/function/section.rb +28 -16
- data/lib/isodoc/function/table.rb +22 -22
- data/lib/isodoc/function/terms.rb +6 -7
- data/lib/isodoc/function/to_word_html.rb +19 -25
- data/lib/isodoc/function/utils.rb +181 -163
- data/lib/isodoc/gem_tasks.rb +8 -9
- data/lib/isodoc/headlesshtml_convert.rb +8 -7
- data/lib/isodoc/html_convert.rb +6 -0
- data/lib/isodoc/html_function/comments.rb +14 -12
- data/lib/isodoc/html_function/footnotes.rb +14 -7
- data/lib/isodoc/html_function/form.rb +62 -0
- data/lib/isodoc/html_function/html.rb +30 -26
- data/lib/isodoc/html_function/postprocess.rb +191 -182
- data/lib/isodoc/html_function/sectionsplit.rb +230 -0
- data/lib/isodoc/i18n.rb +13 -11
- data/lib/isodoc/metadata.rb +22 -20
- data/lib/isodoc/metadata_contributor.rb +31 -28
- data/lib/isodoc/pdf_convert.rb +11 -13
- data/lib/isodoc/presentation_function/bibdata.rb +54 -30
- data/lib/isodoc/presentation_function/inline.rb +70 -120
- data/lib/isodoc/presentation_function/math.rb +84 -0
- data/lib/isodoc/presentation_function/section.rb +55 -19
- data/lib/isodoc/presentation_xml_convert.rb +3 -0
- data/lib/isodoc/sassc_importer.rb +1 -1
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +28 -24
- data/lib/isodoc/word_function/postprocess.rb +50 -36
- data/lib/isodoc/xref.rb +2 -0
- data/lib/isodoc/xref/xref_counter.rb +1 -2
- data/lib/isodoc/xref/xref_gen.rb +21 -14
- data/lib/isodoc/xref/xref_gen_seq.rb +60 -35
- data/lib/isodoc/xref/xref_sect_gen.rb +15 -15
- data/spec/assets/scripts_override.html +3 -0
- data/spec/isodoc/blocks_spec.rb +624 -997
- data/spec/isodoc/cleanup_spec.rb +40 -42
- data/spec/isodoc/form_spec.rb +156 -0
- data/spec/isodoc/i18n_spec.rb +694 -821
- data/spec/isodoc/inline_spec.rb +1105 -921
- data/spec/isodoc/metadata_spec.rb +384 -379
- data/spec/isodoc/postproc_spec.rb +461 -333
- data/spec/isodoc/presentation_xml_spec.rb +355 -278
- data/spec/isodoc/ref_spec.rb +5 -5
- data/spec/isodoc/section_spec.rb +216 -199
- data/spec/isodoc/sectionsplit_spec.rb +190 -0
- data/spec/isodoc/table_spec.rb +41 -42
- data/spec/isodoc/terms_spec.rb +84 -84
- data/spec/isodoc/xref_spec.rb +974 -932
- metadata +32 -7
@@ -3,6 +3,9 @@
|
|
3
3
|
require "spec_helper"
|
4
4
|
require "fileutils"
|
5
5
|
|
6
|
+
options = { wordstylesheet: "spec/assets/word.css",
|
7
|
+
htmlstylesheet: "spec/assets/html.scss" }
|
8
|
+
|
6
9
|
RSpec.describe IsoDoc do
|
7
10
|
it "generates file based on string input" do
|
8
11
|
FileUtils.rm_f "test.doc"
|
@@ -10,7 +13,7 @@ RSpec.describe IsoDoc do
|
|
10
13
|
IsoDoc::HtmlConvert.new(
|
11
14
|
{ wordstylesheet: "spec/assets/word.css",
|
12
15
|
htmlstylesheet: "spec/assets/html.scss",
|
13
|
-
filename: "test" }
|
16
|
+
filename: "test" },
|
14
17
|
).convert("test", <<~"INPUT", false)
|
15
18
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
16
19
|
<bibdata>
|
@@ -37,7 +40,7 @@ RSpec.describe IsoDoc do
|
|
37
40
|
IsoDoc::HtmlConvert.new(
|
38
41
|
{ wordstylesheet: "word.css",
|
39
42
|
htmlstylesheet: "html.scss",
|
40
|
-
filename: "test" }
|
43
|
+
filename: "test" },
|
41
44
|
).convert("spec/assets/test", <<~"INPUT", false)
|
42
45
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
43
46
|
<bibdata>
|
@@ -111,7 +114,7 @@ RSpec.describe IsoDoc do
|
|
111
114
|
FileUtils.rm_f "test.html"
|
112
115
|
IsoDoc::WordConvert.new(
|
113
116
|
{ wordstylesheet: "spec/assets/word.css",
|
114
|
-
htmlstylesheet: "spec/assets/html.scss" }
|
117
|
+
htmlstylesheet: "spec/assets/html.scss" },
|
115
118
|
).convert("test", <<~"INPUT", false)
|
116
119
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
117
120
|
<preface><foreword>
|
@@ -133,7 +136,7 @@ RSpec.describe IsoDoc do
|
|
133
136
|
FileUtils.rm_f "spec/assets/iso.html"
|
134
137
|
IsoDoc::HtmlConvert.new(
|
135
138
|
{ wordstylesheet: "word.css",
|
136
|
-
htmlstylesheet: "html.scss" }
|
139
|
+
htmlstylesheet: "html.scss" },
|
137
140
|
).convert("spec/assets/iso.xml", nil, false)
|
138
141
|
expect(File.exist?("spec/assets/iso.html")).to be true
|
139
142
|
html = File.read("spec/assets/iso.html")
|
@@ -148,7 +151,7 @@ RSpec.describe IsoDoc do
|
|
148
151
|
FileUtils.rm_f "spec/assets/iso.html"
|
149
152
|
IsoDoc::HeadlessHtmlConvert.new(
|
150
153
|
{ wordstylesheet: "word.css",
|
151
|
-
htmlstylesheet: "html.scss" }
|
154
|
+
htmlstylesheet: "html.scss" },
|
152
155
|
).convert("spec/assets/iso.xml", nil, false)
|
153
156
|
expect(File.exist?("spec/assets/iso.headless.html")).to be true
|
154
157
|
html = File.read("spec/assets/iso.headless.html")
|
@@ -165,7 +168,7 @@ RSpec.describe IsoDoc do
|
|
165
168
|
FileUtils.rm_f "spec/assets/iso.doc"
|
166
169
|
IsoDoc::WordConvert.new(
|
167
170
|
{ wordstylesheet: "word.css",
|
168
|
-
htmlstylesheet: "html.scss" }
|
171
|
+
htmlstylesheet: "html.scss" },
|
169
172
|
).convert("spec/assets/iso.xml", nil, false)
|
170
173
|
expect(File.exist?("spec/assets/iso.doc")).to be true
|
171
174
|
word = File.read("spec/assets/iso.doc")
|
@@ -188,9 +191,10 @@ RSpec.describe IsoDoc do
|
|
188
191
|
htmlcoverpage: "spec/assets/htmlcover.html",
|
189
192
|
htmlintropage: "spec/assets/htmlintro.html",
|
190
193
|
scripts: "spec/assets/scripts.html",
|
194
|
+
scripts_override: "spec/assets/scripts_override.html",
|
191
195
|
i18nyaml: "spec/assets/i18n.yaml",
|
192
196
|
ulstyle: "l1",
|
193
|
-
olstyle: "l2" }
|
197
|
+
olstyle: "l2" },
|
194
198
|
).convert("test", <<~"INPUT", false)
|
195
199
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
196
200
|
<preface><foreword>
|
@@ -212,6 +216,7 @@ RSpec.describe IsoDoc do
|
|
212
216
|
expect(html).to match(/an empty html cover page/)
|
213
217
|
expect(html).to match(/an empty html intro page/)
|
214
218
|
expect(html).to match(/This is > a script/)
|
219
|
+
expect(html).to match(/This is > also a script/)
|
215
220
|
expect(html).not_to match(/CDATA/)
|
216
221
|
expect(html).to match(%r{Antaŭparolo</h1>})
|
217
222
|
expect(html).to match(%r{html-override})
|
@@ -227,7 +232,7 @@ RSpec.describe IsoDoc do
|
|
227
232
|
scripts: "spec/assets/scripts.html",
|
228
233
|
i18nyaml: "spec/assets/i18n.yaml",
|
229
234
|
ulstyle: "l1",
|
230
|
-
olstyle: "l2" }
|
235
|
+
olstyle: "l2" },
|
231
236
|
).convert("test", <<~"INPUT", false)
|
232
237
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
233
238
|
<preface><foreword>
|
@@ -272,7 +277,7 @@ RSpec.describe IsoDoc do
|
|
272
277
|
wordintropage: "spec/assets/wordintro.html",
|
273
278
|
i18nyaml: "spec/assets/i18n.yaml",
|
274
279
|
ulstyle: "l1",
|
275
|
-
olstyle: "l2" }
|
280
|
+
olstyle: "l2" },
|
276
281
|
).convert("test", <<~"INPUT", false)
|
277
282
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
278
283
|
<preface><foreword>
|
@@ -311,7 +316,7 @@ RSpec.describe IsoDoc do
|
|
311
316
|
wordintropage: "spec/assets/wordintro.html",
|
312
317
|
i18nyaml: "spec/assets/i18n.yaml",
|
313
318
|
ulstyle: "l1",
|
314
|
-
olstyle: "l2" }
|
319
|
+
olstyle: "l2" },
|
315
320
|
).convert("test", <<~"INPUT", false)
|
316
321
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
317
322
|
<preface><foreword>
|
@@ -344,7 +349,7 @@ RSpec.describe IsoDoc do
|
|
344
349
|
FileUtils.rm_f "test.html"
|
345
350
|
IsoDoc::WordConvert.new(
|
346
351
|
{ wordstylesheet: "spec/assets/word.css",
|
347
|
-
htmlstylesheet: "spec/assets/html.scss" }
|
352
|
+
htmlstylesheet: "spec/assets/html.scss" },
|
348
353
|
).convert("test", <<~"INPUT", false)
|
349
354
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
350
355
|
<preface><foreword>
|
@@ -390,7 +395,7 @@ RSpec.describe IsoDoc do
|
|
390
395
|
FileUtils.rm_f "test.html"
|
391
396
|
IsoDoc::WordConvert.new(
|
392
397
|
{ wordstylesheet: "spec/assets/word.css",
|
393
|
-
htmlstylesheet: "spec/assets/html.scss" }
|
398
|
+
htmlstylesheet: "spec/assets/html.scss" },
|
394
399
|
).convert("test", <<~"INPUT", false)
|
395
400
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
396
401
|
<sections>
|
@@ -426,7 +431,7 @@ RSpec.describe IsoDoc do
|
|
426
431
|
IsoDoc::WordConvert.new(
|
427
432
|
{ wordstylesheet: "spec/assets/word.css",
|
428
433
|
htmlstylesheet: "spec/assets/html.scss",
|
429
|
-
header: "spec/assets/header.html" }
|
434
|
+
header: "spec/assets/header.html" },
|
430
435
|
).convert("test", <<~"INPUT", false)
|
431
436
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
432
437
|
<bibdata type="article">
|
@@ -454,7 +459,7 @@ RSpec.describe IsoDoc do
|
|
454
459
|
IsoDoc::WordConvert.new(
|
455
460
|
{ wordstylesheet: "spec/assets/word.css",
|
456
461
|
htmlstylesheet: "spec/assets/html.scss",
|
457
|
-
wordintropage: "spec/assets/wordintro.html" }
|
462
|
+
wordintropage: "spec/assets/wordintro.html" },
|
458
463
|
).convert("test", <<~"INPUT", false)
|
459
464
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
460
465
|
<sections>
|
@@ -478,55 +483,56 @@ RSpec.describe IsoDoc do
|
|
478
483
|
word = File.read("test.doc")
|
479
484
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
480
485
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
481
|
-
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")))
|
486
|
+
expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc")))
|
487
|
+
.to be_equivalent_to xmlpp(<<~'OUTPUT')
|
482
488
|
<div class="WordSection2">
|
483
|
-
|
489
|
+
/* an empty word intro page */
|
484
490
|
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
491
|
+
<p class="MsoToc1"><span lang="EN-GB" xml:lang="EN-GB"><span style="mso-element:field-begin"></span><span style="mso-spacerun:yes"> </span>TOC
|
492
|
+
\o "1-2" \h \z \u <span style="mso-element:field-separator"></span></span>
|
493
|
+
<span class="MsoHyperlink"><span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
494
|
+
<a href="#_Toc">Clause 4<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
495
|
+
<span style="mso-tab-count:1 dotted">. </span>
|
496
|
+
</span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
497
|
+
<span style="mso-element:field-begin"></span></span>
|
498
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
|
499
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
|
500
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span></span></p>
|
501
|
+
<p class="MsoToc2">
|
502
|
+
<span class="MsoHyperlink">
|
503
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
504
|
+
<a href="#_Toc">Introduction to this<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
505
|
+
<span style="mso-tab-count:1 dotted">. </span>
|
506
|
+
</span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
507
|
+
<span style="mso-element:field-begin"></span></span>
|
508
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
|
509
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
|
510
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
|
511
|
+
</span>
|
512
|
+
</p>
|
513
|
+
<p class="MsoToc2">
|
514
|
+
<span class="MsoHyperlink">
|
515
|
+
<span lang="EN-GB" style="mso-no-proof:yes" xml:lang="EN-GB">
|
516
|
+
<a href="#_Toc">Clause 4.2<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
517
|
+
<span style="mso-tab-count:1 dotted">. </span>
|
518
|
+
</span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">
|
519
|
+
<span style="mso-element:field-begin"></span></span>
|
520
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"> PAGEREF _Toc \h </span>
|
521
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-separator"></span></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB">1</span>
|
522
|
+
<span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"></span><span lang="EN-GB" class="MsoTocTextSpan" xml:lang="EN-GB"><span style="mso-element:field-end"></span></span></a></span>
|
523
|
+
</span>
|
524
|
+
</p>
|
525
|
+
<p class="MsoToc1">
|
526
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
527
|
+
<span style="mso-element:field-end"></span>
|
528
|
+
</span>
|
529
|
+
<span lang="EN-GB" xml:lang="EN-GB">
|
530
|
+
<p class="MsoNormal"> </p>
|
531
|
+
</span>
|
532
|
+
</p>
|
533
|
+
<p class="MsoNormal"> </p>
|
534
|
+
</div>
|
535
|
+
OUTPUT
|
530
536
|
end
|
531
537
|
|
532
538
|
it "populates Word ToC with custom levels" do
|
@@ -535,7 +541,7 @@ RSpec.describe IsoDoc do
|
|
535
541
|
{ wordstylesheet: "spec/assets/word.css",
|
536
542
|
htmlstylesheet: "spec/assets/html.scss",
|
537
543
|
wordintropage: "spec/assets/wordintro.html",
|
538
|
-
doctoclevels: 3 }
|
544
|
+
doctoclevels: 3 },
|
539
545
|
).convert("test", <<~"INPUT", false)
|
540
546
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
541
547
|
<sections>
|
@@ -648,7 +654,7 @@ RSpec.describe IsoDoc do
|
|
648
654
|
IsoDoc::HtmlConvert.new(
|
649
655
|
{ wordstylesheet: "spec/assets/word.css",
|
650
656
|
htmlstylesheet: "spec/assets/html.scss",
|
651
|
-
wordintropage: "spec/assets/wordintro.html" }
|
657
|
+
wordintropage: "spec/assets/wordintro.html" },
|
652
658
|
).convert("test", <<~"INPUT", false)
|
653
659
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
654
660
|
<sections>
|
@@ -669,7 +675,8 @@ RSpec.describe IsoDoc do
|
|
669
675
|
</iso-standard>
|
670
676
|
INPUT
|
671
677
|
html = File.read("test.html")
|
672
|
-
.sub(/^.*<main class="main-section">/m,
|
678
|
+
.sub(/^.*<main class="main-section">/m,
|
679
|
+
'<main xmlns:epub="epub" class="main-section">')
|
673
680
|
.sub(%r{</main>.*$}m, "</main>")
|
674
681
|
expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
675
682
|
<main xmlns:epub="epub" class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
@@ -704,7 +711,7 @@ RSpec.describe IsoDoc do
|
|
704
711
|
FileUtils.rm_rf "test_htmlimages"
|
705
712
|
IsoDoc::HtmlConvert.new(
|
706
713
|
{ wordstylesheet: "spec/assets/word.css",
|
707
|
-
htmlstylesheet: "spec/assets/html.scss" }
|
714
|
+
htmlstylesheet: "spec/assets/html.scss" },
|
708
715
|
).convert("test", <<~"INPUT", false)
|
709
716
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
710
717
|
<preface><foreword>
|
@@ -913,7 +920,7 @@ RSpec.describe IsoDoc do
|
|
913
920
|
FileUtils.rm_rf "test_htmlimages"
|
914
921
|
IsoDoc::HtmlConvert.new(
|
915
922
|
{ wordstylesheet: "spec/assets/word.css",
|
916
|
-
htmlstylesheet: "spec/assets/html.scss" }
|
923
|
+
htmlstylesheet: "spec/assets/html.scss" },
|
917
924
|
).convert("test", <<~"INPUT", false)
|
918
925
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
919
926
|
<preface><foreword>
|
@@ -952,154 +959,167 @@ RSpec.describe IsoDoc do
|
|
952
959
|
it "moves images in HTML, using relative file location" do
|
953
960
|
FileUtils.rm_f "spec/test.html"
|
954
961
|
FileUtils.rm_rf "spec/test_htmlimages"
|
955
|
-
IsoDoc::HtmlConvert
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
962
|
+
IsoDoc::HtmlConvert
|
963
|
+
.new(wordstylesheet: "assets/word.css",
|
964
|
+
htmlstylesheet: "assets/html.scss")
|
965
|
+
.convert("spec/test", <<~"INPUT", false)
|
966
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
967
|
+
<preface><foreword>
|
968
|
+
<figure id="_">
|
969
|
+
<name>Split-it-right sample divider</name>
|
970
|
+
<image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/>
|
971
|
+
<image src="assets/rice_image1.png" id="_" mimetype="image/png"/>
|
972
|
+
<image src="assets/rice_image1.png" id="_" width="20000" height="300000" mimetype="image/png"/>
|
973
|
+
<image src="assets/rice_image1.png" id="_" width="99" height="auto" mimetype="image/png"/>
|
974
|
+
</figure>
|
975
|
+
</foreword></preface>
|
976
|
+
</iso-standard>
|
977
|
+
INPUT
|
968
978
|
html = File.read("spec/test.html")
|
969
979
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
970
980
|
.sub(%r{</main>.*$}m, "</main>")
|
971
981
|
expect(`ls test_htmlimages`).to match(/\.png$/)
|
972
|
-
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")))
|
973
|
-
|
974
|
-
<
|
975
|
-
|
976
|
-
<
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
982
|
+
expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png")))
|
983
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
984
|
+
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
985
|
+
<br />
|
986
|
+
<div>
|
987
|
+
<h1 class="ForewordTitle">Foreword</h1>
|
988
|
+
<div id="_" class="figure">
|
989
|
+
<img src="test_htmlimages/_.png" height="776" width="922" />
|
990
|
+
<img src="test_htmlimages/_.png" height="776" width="922" />
|
991
|
+
<img src="test_htmlimages/_.png" height="800" width="53" />
|
992
|
+
<img src="test_htmlimages/_.png" height="83" width="99" />
|
993
|
+
<p class="FigureTitle" style="text-align:center;">Split-it-right sample divider</p></div>
|
994
|
+
</div>
|
995
|
+
<p class="zzSTDTitle1"></p>
|
996
|
+
</main>
|
997
|
+
OUTPUT
|
987
998
|
end
|
988
999
|
|
989
1000
|
it "encodes images in HTML as data URIs" do
|
990
1001
|
FileUtils.rm_f "test.html"
|
991
1002
|
FileUtils.rm_rf "test_htmlimages"
|
992
|
-
IsoDoc::HtmlConvert
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
+
IsoDoc::HtmlConvert
|
1004
|
+
.new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true)
|
1005
|
+
.convert("test", <<~"INPUT", false)
|
1006
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1007
|
+
<preface><foreword>
|
1008
|
+
<figure id="_">
|
1009
|
+
<name>Split-it-right sample divider</name>
|
1010
|
+
<image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/>
|
1011
|
+
<image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
|
1012
|
+
</figure>
|
1013
|
+
</foreword></preface>
|
1014
|
+
</iso-standard>
|
1015
|
+
INPUT
|
1003
1016
|
html = File.read("test.html")
|
1004
1017
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
1005
1018
|
.sub(%r{</main>.*$}m, "</main>")
|
1006
|
-
expect(xmlpp(html
|
1007
|
-
|
1008
|
-
|
1009
|
-
<
|
1010
|
-
<
|
1011
|
-
<div
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
+
expect(xmlpp(html
|
1020
|
+
.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
|
1021
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1022
|
+
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
1023
|
+
<br />
|
1024
|
+
<div>
|
1025
|
+
<h1 class="ForewordTitle">Foreword</h1>
|
1026
|
+
<div id="_" class="figure">
|
1027
|
+
<img src="data:image/png;base64,_" height="776" width="922" />
|
1028
|
+
<img src="data:image/png;base64,_" height="776" width="922" />
|
1029
|
+
<p class="FigureTitle" style="text-align:center;">Split-it-right sample divider</p></div>
|
1030
|
+
</div>
|
1031
|
+
<p class="zzSTDTitle1"></p>
|
1032
|
+
</main>
|
1033
|
+
OUTPUT
|
1019
1034
|
end
|
1020
1035
|
|
1021
1036
|
it "encodes images in HTML as data URIs, using relative file location" do
|
1022
1037
|
FileUtils.rm_f "spec/test.html"
|
1023
1038
|
FileUtils.rm_rf "spec/test_htmlimages"
|
1024
|
-
IsoDoc::HtmlConvert
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1039
|
+
IsoDoc::HtmlConvert
|
1040
|
+
.new({ htmlstylesheet: "assets/html.scss", datauriimage: true })
|
1041
|
+
.convert("spec/test", <<~"INPUT", false)
|
1042
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1043
|
+
<preface><foreword>
|
1044
|
+
<figure id="_">
|
1045
|
+
<name>Split-it-right sample divider</name>
|
1046
|
+
<image src="#{File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets/rice_image1.png'))}" id="_" mimetype="image/png"/>
|
1047
|
+
<image src="assets/rice_image1.png" id="_" mimetype="image/png"/>
|
1048
|
+
</figure>
|
1049
|
+
</foreword></preface>
|
1050
|
+
</iso-standard>
|
1051
|
+
INPUT
|
1035
1052
|
html = File.read("spec/test.html")
|
1036
1053
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
1037
1054
|
.sub(%r{</main>.*$}m, "</main>")
|
1038
|
-
expect(xmlpp(html
|
1039
|
-
|
1040
|
-
|
1041
|
-
<
|
1042
|
-
<
|
1043
|
-
<div
|
1044
|
-
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
1055
|
+
expect(xmlpp(html
|
1056
|
+
.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"})))
|
1057
|
+
.to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1058
|
+
<main class="main-section"><button onclick="topFunction()" id="myBtn" title="Go to top">Top</button>
|
1059
|
+
<br />
|
1060
|
+
<div>
|
1061
|
+
<h1 class="ForewordTitle">Foreword</h1>
|
1062
|
+
<div id="_" class="figure">
|
1063
|
+
<img src="data:image/png;base64,_" height="776" width="922" />
|
1064
|
+
<img src="data:image/png;base64,_" height="776" width="922" />
|
1065
|
+
<p class="FigureTitle" style="text-align:center;">Split-it-right sample divider</p></div>
|
1066
|
+
</div>
|
1067
|
+
<p class="zzSTDTitle1"></p>
|
1068
|
+
</main>
|
1069
|
+
OUTPUT
|
1051
1070
|
end
|
1052
1071
|
|
1053
1072
|
it "processes IsoXML terms for HTML" do
|
1054
1073
|
FileUtils.rm_f "test.html"
|
1055
1074
|
FileUtils.rm_f "test.doc"
|
1056
|
-
IsoDoc::HtmlConvert.new(
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
<
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
<
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
<
|
1076
|
-
<
|
1077
|
-
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1084
|
-
|
1085
|
-
<
|
1086
|
-
|
1087
|
-
|
1088
|
-
|
1089
|
-
|
1090
|
-
<
|
1091
|
-
|
1092
|
-
|
1093
|
-
|
1094
|
-
<
|
1095
|
-
|
1096
|
-
|
1097
|
-
<
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1075
|
+
IsoDoc::HtmlConvert.new(options)
|
1076
|
+
.convert("test", <<~"INPUT", false)
|
1077
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1078
|
+
<sections>
|
1079
|
+
<terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
|
1080
|
+
<term id="paddy1"><name>1.1.</name><preferred>paddy</preferred>
|
1081
|
+
<domain>rice</domain>
|
1082
|
+
<definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
|
1083
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
|
1084
|
+
<p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
|
1085
|
+
<ul>
|
1086
|
+
<li>A</li>
|
1087
|
+
</ul>
|
1088
|
+
</termexample>
|
1089
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
|
1090
|
+
<ul>
|
1091
|
+
<li>A</li>
|
1092
|
+
</ul>
|
1093
|
+
</termexample>
|
1094
|
+
<termsource status="modified">
|
1095
|
+
<origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
|
1096
|
+
<modification>
|
1097
|
+
<p id="_e73a417d-ad39-417d-a4c8-20e4e2529489">The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here</p>
|
1098
|
+
</modification>
|
1099
|
+
</termsource></term>
|
1100
|
+
<term id="paddy"><name>1.2.</name><preferred>paddy</preferred><admitted>paddy rice</admitted>
|
1101
|
+
<admitted>rough rice</admitted>
|
1102
|
+
<deprecates>cargo rice</deprecates>
|
1103
|
+
<definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
|
1104
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f893">
|
1105
|
+
<ul>
|
1106
|
+
<li>A</li>
|
1107
|
+
</ul>
|
1108
|
+
</termexample>
|
1109
|
+
<termnote id="_671a1994-4783-40d0-bc81-987d06ffb74e">
|
1110
|
+
<p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
|
1111
|
+
</termnote>
|
1112
|
+
<termnote id="_671a1994-4783-40d0-bc81-987d06ffb74f">
|
1113
|
+
<ul><li>A</li></ul>
|
1114
|
+
<p id="_19830f33-e46c-42cc-94ca-a5ef101132d5">The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.</p>
|
1115
|
+
</termnote>
|
1116
|
+
<termsource status="identical">
|
1117
|
+
<origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011"><locality type="clause"><referenceFrom>3.1</referenceFrom></locality></origin>
|
1118
|
+
</termsource></term>
|
1119
|
+
</terms>
|
1120
|
+
</sections>
|
1121
|
+
</iso-standard>
|
1122
|
+
INPUT
|
1103
1123
|
expect(File.exist?("test.html")).to be true
|
1104
1124
|
html = File.read("test.html")
|
1105
1125
|
expect(html).to match(%r{<h2 class="TermNum" id="paddy1">1\.1\.</h2>})
|
@@ -1109,34 +1129,35 @@ RSpec.describe IsoDoc do
|
|
1109
1129
|
it "processes empty term modifications" do
|
1110
1130
|
FileUtils.rm_f "test.html"
|
1111
1131
|
FileUtils.rm_f "test.doc"
|
1112
|
-
IsoDoc::HtmlConvert.new(
|
1113
|
-
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
|
1119
|
-
|
1120
|
-
<
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
1126
|
-
<
|
1127
|
-
|
1128
|
-
|
1129
|
-
|
1130
|
-
|
1131
|
-
<
|
1132
|
-
<
|
1133
|
-
|
1134
|
-
|
1135
|
-
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
|
1132
|
+
IsoDoc::HtmlConvert.new(options)
|
1133
|
+
.convert("test", <<~"INPUT", false)
|
1134
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1135
|
+
<sections>
|
1136
|
+
<terms id="_terms_and_definitions" obligation="normative"><title>Terms and Definitions</title>
|
1137
|
+
<term id="paddy1"><preferred>paddy</preferred>
|
1138
|
+
<domain>rice</domain>
|
1139
|
+
<definition><p id="_eb29b35e-123e-4d1c-b50b-2714d41e747f">rice retaining its husk after threshing</p></definition>
|
1140
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f892">
|
1141
|
+
<p id="_65c9a509-9a89-4b54-a890-274126aeb55c">Foreign seeds, husks, bran, sand, dust.</p>
|
1142
|
+
<ul>
|
1143
|
+
<li>A</li>
|
1144
|
+
</ul>
|
1145
|
+
</termexample>
|
1146
|
+
<termexample id="_bd57bbf1-f948-4bae-b0ce-73c00431f894">
|
1147
|
+
<ul>
|
1148
|
+
<li>A</li>
|
1149
|
+
</ul>
|
1150
|
+
</termexample>
|
1151
|
+
<termsource status="modified">
|
1152
|
+
<origin bibitemid="ISO7301" type="inline" citeas="ISO 7301:2011">ISO 7301:2011, Clause 3.1</origin>
|
1153
|
+
<modification>
|
1154
|
+
<p id="_e73a417d-ad39-417d-a4c8-20e4e2529489"/>
|
1155
|
+
</modification>
|
1156
|
+
</termsource></term>
|
1157
|
+
</terms>
|
1158
|
+
</sections>
|
1159
|
+
</iso-standard>
|
1160
|
+
INPUT
|
1140
1161
|
expect(File.exist?("test.html")).to be true
|
1141
1162
|
html = File.read("test.html")
|
1142
1163
|
expect(html).to include '[SOURCE: <a href="#ISO7301">ISO 7301:2011, Clause 3.1</a>, modified]'
|
@@ -1145,37 +1166,38 @@ RSpec.describe IsoDoc do
|
|
1145
1166
|
it "creates continuation styles for multiparagraph list items in Word" do
|
1146
1167
|
FileUtils.rm_f "test.doc"
|
1147
1168
|
FileUtils.rm_f "test.html"
|
1148
|
-
IsoDoc::WordConvert.new(
|
1149
|
-
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
1169
|
-
|
1170
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1176
|
-
|
1177
|
-
|
1178
|
-
|
1169
|
+
IsoDoc::WordConvert.new(options)
|
1170
|
+
.convert("test", <<~"INPUT", false)
|
1171
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1172
|
+
<preface><foreword>
|
1173
|
+
<ul>
|
1174
|
+
<li><p>A</p>
|
1175
|
+
<p>B</p></li>
|
1176
|
+
<li><ol><li><p>C</p>
|
1177
|
+
<p>D</p>
|
1178
|
+
<sourcecode>E</sourcecode></li>
|
1179
|
+
</ol></li>
|
1180
|
+
</ul>
|
1181
|
+
<ol>
|
1182
|
+
<li><p>A1</p>
|
1183
|
+
<p>B1</p></li>
|
1184
|
+
<li><ul><li><p>C1</p>
|
1185
|
+
<formula id="_5fc1ef0f-75d2-4b54-802c-b1bad4a53b62">
|
1186
|
+
<stem type="AsciiMath">D1</stem>
|
1187
|
+
</formula>
|
1188
|
+
<dl id="_f8fb7ed7-7874-44a8-933f-06e0e86fb264">
|
1189
|
+
<dt>
|
1190
|
+
<em>n</em>
|
1191
|
+
</dt>
|
1192
|
+
<dd>
|
1193
|
+
<p id="_a27281a4-b20e-4d0b-a780-bab9e851b03e">is the number of coating layers</p>
|
1194
|
+
</dd>
|
1195
|
+
</dl>
|
1196
|
+
</ul></li>
|
1197
|
+
</ol>
|
1198
|
+
</foreword></preface>
|
1199
|
+
</iso-standard>
|
1200
|
+
INPUT
|
1179
1201
|
word = File.read("test.doc")
|
1180
1202
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2" xmlns:m="m">')
|
1181
1203
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
@@ -1255,16 +1277,17 @@ RSpec.describe IsoDoc do
|
|
1255
1277
|
it "does not lose HTML escapes in postprocessing" do
|
1256
1278
|
FileUtils.rm_f "test.doc"
|
1257
1279
|
FileUtils.rm_f "test.html"
|
1258
|
-
IsoDoc::HtmlConvert.new(
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1280
|
+
IsoDoc::HtmlConvert.new(options)
|
1281
|
+
.convert("test", <<~"INPUT", false)
|
1282
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1283
|
+
<preface><foreword>
|
1284
|
+
<sourcecode id="samplecode">
|
1285
|
+
<name>XML code</name>
|
1286
|
+
<xml> &
|
1287
|
+
</sourcecode>
|
1288
|
+
</foreword></preface>
|
1289
|
+
</iso-standard>
|
1290
|
+
INPUT
|
1268
1291
|
html = File.read("test.html")
|
1269
1292
|
.sub(/^.*<main class="main-section">/m, '<main class="main-section">')
|
1270
1293
|
.sub(%r{</main>.*$}m, "</main>")
|
@@ -1285,16 +1308,17 @@ RSpec.describe IsoDoc do
|
|
1285
1308
|
it "does not lose HTML escapes in postprocessing (Word)" do
|
1286
1309
|
FileUtils.rm_f "test.doc"
|
1287
1310
|
FileUtils.rm_f "test.html"
|
1288
|
-
IsoDoc::WordConvert.new(
|
1289
|
-
|
1290
|
-
|
1291
|
-
|
1292
|
-
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
1311
|
+
IsoDoc::WordConvert.new(options)
|
1312
|
+
.convert("test", <<~"INPUT", false)
|
1313
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1314
|
+
<preface><foreword>
|
1315
|
+
<sourcecode id="samplecode">
|
1316
|
+
<name>XML code</name>
|
1317
|
+
<xml> &
|
1318
|
+
</sourcecode>
|
1319
|
+
</foreword></preface>
|
1320
|
+
</iso-standard>
|
1321
|
+
INPUT
|
1298
1322
|
word = File.read("test.doc")
|
1299
1323
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
1300
1324
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
@@ -1315,7 +1339,7 @@ RSpec.describe IsoDoc do
|
|
1315
1339
|
it "propagates example style to paragraphs in postprocessing (Word)" do
|
1316
1340
|
FileUtils.rm_f "test.doc"
|
1317
1341
|
FileUtils.rm_f "test.html"
|
1318
|
-
IsoDoc::WordConvert.new(
|
1342
|
+
IsoDoc::WordConvert.new(options).convert("test", <<~"INPUT", false)
|
1319
1343
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1320
1344
|
<preface><foreword>
|
1321
1345
|
<example id="samplecode">
|
@@ -1346,16 +1370,17 @@ RSpec.describe IsoDoc do
|
|
1346
1370
|
it "deals with image captions (Word)" do
|
1347
1371
|
FileUtils.rm_f "test.doc"
|
1348
1372
|
FileUtils.rm_f "test.html"
|
1349
|
-
IsoDoc::WordConvert.new(
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
<
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1373
|
+
IsoDoc::WordConvert.new(options)
|
1374
|
+
.convert("test", <<~"INPUT", false)
|
1375
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1376
|
+
<preface><foreword>
|
1377
|
+
<figure id="fig1">
|
1378
|
+
<name>Typical arrangement of the far-field scan set-up</name>
|
1379
|
+
<image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/>
|
1380
|
+
</figure>
|
1381
|
+
</foreword></preface>
|
1382
|
+
</iso-standard>
|
1383
|
+
INPUT
|
1359
1384
|
word = File.read("test.doc")
|
1360
1385
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">')
|
1361
1386
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
@@ -1379,20 +1404,21 @@ RSpec.describe IsoDoc do
|
|
1379
1404
|
it "deals with empty table titles (Word)" do
|
1380
1405
|
FileUtils.rm_f "test.doc"
|
1381
1406
|
FileUtils.rm_f "test.html"
|
1382
|
-
IsoDoc::WordConvert.new(
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
<
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1395
|
-
|
1407
|
+
IsoDoc::WordConvert.new(options)
|
1408
|
+
.convert("test", <<~"INPUT", false)
|
1409
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1410
|
+
<preface><foreword>
|
1411
|
+
<table id="_fe12b8f8-6858-4cd6-af7d-d4b6f3ebd1a7" unnumbered="true"><thead><tr>
|
1412
|
+
<td rowspan="2">
|
1413
|
+
<p id="_c47d9b39-adb2-431d-9320-78cb148fdb56">Output wavelength <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mo>(</mo><mi>μ</mi><mi>m</mi><mo>)</mo></mrow></math></stem></p>
|
1414
|
+
</td>
|
1415
|
+
<th colspan="3" align="left">Predictive wavelengths</th>
|
1416
|
+
</tr>
|
1417
|
+
</thead>
|
1418
|
+
</table>
|
1419
|
+
</preface>
|
1420
|
+
</iso-standard>
|
1421
|
+
INPUT
|
1396
1422
|
word = File.read("test.doc")
|
1397
1423
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2" xmlns:m="m">')
|
1398
1424
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
@@ -1439,21 +1465,22 @@ RSpec.describe IsoDoc do
|
|
1439
1465
|
it "propagates alignment of table cells (Word)" do
|
1440
1466
|
FileUtils.rm_f "test.doc"
|
1441
1467
|
FileUtils.rm_f "test.html"
|
1442
|
-
IsoDoc::WordConvert.new(
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
|
1468
|
+
IsoDoc::WordConvert.new(options)
|
1469
|
+
.convert("test", <<~"INPUT", false)
|
1470
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
1471
|
+
<preface><foreword>
|
1472
|
+
<table id="_fe12b8f8-6858-4cd6-af7d-d4b6f3ebd1a7" unnumbered="true"><thead><tr>
|
1473
|
+
<td rowspan="2" align="left">
|
1474
|
+
<p id="_c47d9b39-adb2-431d-9320-78cb148fdb56">Output wavelength</p>
|
1475
|
+
<p id="_c47d9b39-adb2-431d-9320-78cb148fdb57">Output wavelength</p>
|
1476
|
+
</td>
|
1477
|
+
<th colspan="3" align="right"><p id="_c47d9b39-adb2-431d-9320-78cb148fdb58">Predictive wavelengths</p></th>
|
1478
|
+
</tr>
|
1479
|
+
</thead>
|
1480
|
+
</table>
|
1481
|
+
</preface>
|
1482
|
+
</iso-standard>
|
1483
|
+
INPUT
|
1457
1484
|
word = File.read("test.doc")
|
1458
1485
|
.sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2" xmlns:m="m">')
|
1459
1486
|
.sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "")
|
@@ -1497,7 +1524,7 @@ RSpec.describe IsoDoc do
|
|
1497
1524
|
end
|
1498
1525
|
|
1499
1526
|
it "cleans up boilerplate" do
|
1500
|
-
|
1527
|
+
input = <<~INPUT
|
1501
1528
|
<html>
|
1502
1529
|
<head/>
|
1503
1530
|
<body>
|
@@ -1515,6 +1542,7 @@ RSpec.describe IsoDoc do
|
|
1515
1542
|
</body>
|
1516
1543
|
</html>
|
1517
1544
|
INPUT
|
1545
|
+
html = <<~OUTPUT
|
1518
1546
|
<main class='main-section'>
|
1519
1547
|
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
|
1520
1548
|
<hr/>
|
@@ -1532,27 +1560,7 @@ RSpec.describe IsoDoc do
|
|
1532
1560
|
</div>
|
1533
1561
|
</main>
|
1534
1562
|
OUTPUT
|
1535
|
-
|
1536
|
-
|
1537
|
-
it "cleans up boilerplate (Word)" do
|
1538
|
-
expect(xmlpp(IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }).word_cleanup(Nokogiri::XML(<<~INPUT)).to_xml).sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>")).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
1539
|
-
<html>
|
1540
|
-
<head/>
|
1541
|
-
<body>
|
1542
|
-
<div class="main-section">
|
1543
|
-
<div id="boilerplate-copyright"> <h1>Copyright</h1> </div>
|
1544
|
-
<div id="boilerplate-license"> <h1>License</h1> </div>
|
1545
|
-
<div id="boilerplate-legal"> <h1>Legal</h1> </div>
|
1546
|
-
<div id="boilerplate-feedback"> <h1>Feedback</h1> </div>
|
1547
|
-
<hr/>
|
1548
|
-
<div id="boilerplate-feedback-destination"/>
|
1549
|
-
<div id="boilerplate-legal-destination"/>
|
1550
|
-
<div id="boilerplate-license-destination"/>
|
1551
|
-
<div id="boilerplate-copyright-destination"/>
|
1552
|
-
</div>
|
1553
|
-
</body>
|
1554
|
-
</html>
|
1555
|
-
INPUT
|
1563
|
+
doc = <<~OUTPUT
|
1556
1564
|
<html>
|
1557
1565
|
<head/>
|
1558
1566
|
<body>
|
@@ -1574,13 +1582,25 @@ RSpec.describe IsoDoc do
|
|
1574
1582
|
</body>
|
1575
1583
|
</html>
|
1576
1584
|
OUTPUT
|
1585
|
+
expect(xmlpp(IsoDoc::HtmlConvert
|
1586
|
+
.new(wordstylesheet: "spec/assets/word.css",
|
1587
|
+
htmlstylesheet: "spec/assets/html.scss", filename: "test")
|
1588
|
+
.html_preface(Nokogiri::XML(input)).to_xml)
|
1589
|
+
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
|
1590
|
+
.to be_equivalent_to xmlpp(html)
|
1591
|
+
expect(xmlpp(IsoDoc::WordConvert
|
1592
|
+
.new(wordstylesheet: "spec/assets/word.css",
|
1593
|
+
htmlstylesheet: "spec/assets/html.scss", filename: "test")
|
1594
|
+
.word_cleanup(Nokogiri::XML(input)).to_xml)
|
1595
|
+
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
|
1596
|
+
.to be_equivalent_to xmlpp(doc)
|
1577
1597
|
end
|
1578
1598
|
|
1579
1599
|
it "deals with landscape and portrait pagebreaks (Word)" do
|
1580
1600
|
FileUtils.rm_f "test.doc"
|
1581
1601
|
IsoDoc::WordConvert.new(
|
1582
1602
|
{ wordstylesheet: "spec/assets/word.css",
|
1583
|
-
htmlstylesheet: "spec/assets/html.scss", filename: "test" }
|
1603
|
+
htmlstylesheet: "spec/assets/html.scss", filename: "test" },
|
1584
1604
|
).convert("test", <<~"INPUT", false)
|
1585
1605
|
<standard-document xmlns="http://riboseinc.com/isoxml">
|
1586
1606
|
<bibdata type="standard">
|
@@ -1776,7 +1796,7 @@ RSpec.describe IsoDoc do
|
|
1776
1796
|
end
|
1777
1797
|
|
1778
1798
|
it "expands out nested tables in Word" do
|
1779
|
-
|
1799
|
+
input = <<~INPUT
|
1780
1800
|
<html>
|
1781
1801
|
<head/>
|
1782
1802
|
<body>
|
@@ -1798,6 +1818,7 @@ RSpec.describe IsoDoc do
|
|
1798
1818
|
</body>
|
1799
1819
|
</html>
|
1800
1820
|
INPUT
|
1821
|
+
output = <<~OUTPUT
|
1801
1822
|
<html>
|
1802
1823
|
<head/>
|
1803
1824
|
<body>
|
@@ -1893,10 +1914,16 @@ RSpec.describe IsoDoc do
|
|
1893
1914
|
</body>
|
1894
1915
|
</html>
|
1895
1916
|
OUTPUT
|
1917
|
+
expect(xmlpp(IsoDoc::WordConvert
|
1918
|
+
.new(wordstylesheet: "spec/assets/word.css",
|
1919
|
+
htmlstylesheet: "spec/assets/html.scss", filename: "test")
|
1920
|
+
.word_cleanup(Nokogiri::XML(input)).to_xml)
|
1921
|
+
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
|
1922
|
+
.to be_equivalent_to xmlpp(output)
|
1896
1923
|
end
|
1897
1924
|
|
1898
1925
|
it "allocate widths to tables (Word)" do
|
1899
|
-
|
1926
|
+
input = <<~INPUT
|
1900
1927
|
<html xmlns:epub="http://www.idpf.org/2007/ops" lang="en">
|
1901
1928
|
<head><style/></head>
|
1902
1929
|
<body lang='EN-US' link='blue' vlink='#954F72'>
|
@@ -2030,6 +2057,7 @@ RSpec.describe IsoDoc do
|
|
2030
2057
|
</body>
|
2031
2058
|
</html>
|
2032
2059
|
INPUT
|
2060
|
+
output = <<~OUTPUT
|
2033
2061
|
<html xmlns:epub='http://www.idpf.org/2007/ops' lang='en'>
|
2034
2062
|
<head>
|
2035
2063
|
<style/>
|
@@ -2165,5 +2193,105 @@ RSpec.describe IsoDoc do
|
|
2165
2193
|
</body>
|
2166
2194
|
</html>
|
2167
2195
|
OUTPUT
|
2196
|
+
expect(xmlpp(IsoDoc::WordConvert
|
2197
|
+
.new(wordstylesheet: "spec/assets/word.css",
|
2198
|
+
htmlstylesheet: "spec/assets/html.scss", filename: "test")
|
2199
|
+
.word_cleanup(Nokogiri::XML(input)).to_xml)
|
2200
|
+
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
|
2201
|
+
.to be_equivalent_to xmlpp(output)
|
2202
|
+
end
|
2203
|
+
|
2204
|
+
it "generates bare HTML file" do
|
2205
|
+
FileUtils.rm_f "test.html"
|
2206
|
+
IsoDoc::HtmlConvert.new(
|
2207
|
+
{ bare: true,
|
2208
|
+
htmlstylesheet: "spec/assets/html.scss",
|
2209
|
+
filename: "test" },
|
2210
|
+
).convert("test", <<~"INPUT", false)
|
2211
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
2212
|
+
<bibdata>
|
2213
|
+
<title language="en">test</title>
|
2214
|
+
</bibdata>
|
2215
|
+
<boilerplate>
|
2216
|
+
<feedback-statement>
|
2217
|
+
<clause><title>I am boilerplate</title></clause>
|
2218
|
+
</feedback-statement>
|
2219
|
+
</boilerplate>
|
2220
|
+
<preface><foreword>
|
2221
|
+
<note>
|
2222
|
+
<p id="_f06fd0d1-a203-4f3d-a515-0bdba0f8d83f">These results are based on a study carried out on three different types of kernel.</p>
|
2223
|
+
</note>
|
2224
|
+
</foreword></preface>
|
2225
|
+
</iso-standard>
|
2226
|
+
INPUT
|
2227
|
+
output = <<~OUTPUT
|
2228
|
+
<body lang='en' xml:lang='en'>
|
2229
|
+
<main class='main-section'>
|
2230
|
+
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
|
2231
|
+
<br/>
|
2232
|
+
<div>
|
2233
|
+
<h1 class='ForewordTitle'>Foreword</h1>
|
2234
|
+
<div class='Note'>
|
2235
|
+
<p>
|
2236
|
+
  These results are based on a study carried out on three
|
2237
|
+
different types of kernel.
|
2238
|
+
</p>
|
2239
|
+
</div>
|
2240
|
+
</div>
|
2241
|
+
<p class='zzSTDTitle1'>test</p>
|
2242
|
+
</main>
|
2243
|
+
<script/>
|
2244
|
+
</body>
|
2245
|
+
OUTPUT
|
2246
|
+
expect(File.exist?("test.html")).to be true
|
2247
|
+
html = File.read("test.html")
|
2248
|
+
.sub(%r{^.*<body}m, "<body")
|
2249
|
+
.sub(%r{</body>.*$}m, "</body>")
|
2250
|
+
.gsub(%r{<script.+?</script>}m, "<script/>")
|
2251
|
+
.sub(%r{(<script/>\s+)+}m, "<script/>")
|
2252
|
+
expect(xmlpp(html)).to be_equivalent_to xmlpp(output)
|
2253
|
+
end
|
2254
|
+
|
2255
|
+
it "cleans up lists (HTML)" do
|
2256
|
+
input = <<~INPUT
|
2257
|
+
<html xmlns:epub="http://www.idpf.org/2007/ops">
|
2258
|
+
<head/>
|
2259
|
+
<body>
|
2260
|
+
<div class="main-section">
|
2261
|
+
<ul>
|
2262
|
+
<div>N1</div>
|
2263
|
+
<li>A</li>
|
2264
|
+
<li>B</li>
|
2265
|
+
<div>N2</div>
|
2266
|
+
<li>C</li>
|
2267
|
+
<div>N3</div>
|
2268
|
+
</div>
|
2269
|
+
</body>
|
2270
|
+
</html>
|
2271
|
+
INPUT
|
2272
|
+
output = <<~OUTPUT
|
2273
|
+
<main class='main-section'>
|
2274
|
+
<button onclick='topFunction()' id='myBtn' title='Go to top'>Top</button>
|
2275
|
+
<ul>
|
2276
|
+
<li>
|
2277
|
+
A
|
2278
|
+
<div>N1</div>
|
2279
|
+
</li>
|
2280
|
+
<li>
|
2281
|
+
B
|
2282
|
+
<div>N2</div>
|
2283
|
+
</li>
|
2284
|
+
<li>
|
2285
|
+
C
|
2286
|
+
<div>N3</div>
|
2287
|
+
</li>
|
2288
|
+
</ul>
|
2289
|
+
</main>
|
2290
|
+
OUTPUT
|
2291
|
+
expect(xmlpp(IsoDoc::HtmlConvert
|
2292
|
+
.new(htmlstylesheet: "spec/assets/html.scss", filename: "test")
|
2293
|
+
.html_cleanup(Nokogiri::XML(input)).to_xml)
|
2294
|
+
.sub(/^.*<main/m, "<main").sub(%r{</main>.*$}m, "</main>"))
|
2295
|
+
.to be_equivalent_to xmlpp(output)
|
2168
2296
|
end
|
2169
2297
|
end
|