# frozen_string_literal: true require "spec_helper" require "fileutils" options = { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" } RSpec.describe IsoDoc do it "generates file based on string input" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", filename: "test" }, ).convert("test", <<~"INPUT", false) test

These results are based on a study carried out on three different types of kernel.

INPUT expect(File.exist?("test.html")).to be true html = File.read("test.html") expect(html).to match(%r{test}) expect(html).to match(/another empty stylesheet/) expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/}) expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/) end it "generates file in a remote directory" do FileUtils.rm_f "spec/assets/test.doc" FileUtils.rm_f "spec/assets/test.html" IsoDoc::HtmlConvert.new( { wordstylesheet: "word.css", htmlstylesheet: "html.scss", filename: "test" }, ).convert("spec/assets/test", <<~"INPUT", false) test

These results are based on a study carried out on three different types of kernel.

INPUT expect(File.exist?("spec/assets/test.html")).to be true html = File.read("spec/assets/test.html") expect(html).to match(%r{test}) expect(html).to match(/another empty stylesheet/) end it "ignores Liquid markup in the document body" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" input = <<~INPUT test

{% elif %}These results are based on a study carried out on three different types of kernel.

INPUT IsoDoc::HtmlConvert.new(wordstylesheet: "spec/assets/word.css") .convert("test", input, false) IsoDoc::WordConvert.new({ wordstylesheet: "spec/assets/word.css" }) .convert("test", input, false) expect(File.exist?("test.html")).to be true html = File.read("test.html") expect(html).to match(%r/\{% elif %}/) expect(File.exist?("test.doc")).to be true html = File.read("test.doc") expect(html).to match(%r/\{% elif %}/) end it "generates HTML output docs with null configuration" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new({ wordstylesheet: "spec/assets/word.css" }) .convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT expect(File.exist?("test.html")).to be true html = File.read("test.html") expect(html).not_to match(%r{test}) expect(html).not_to match(/another empty stylesheet/) expect(html).to match(%r{cdnjs\.cloudflare\.com/ajax/libs/mathjax/}) expect(html).to match(/delimiters: \[\['\(#\(', '\)#\)'\]\]/) expect(html).not_to match(/html-override/) end it "generates Word output docs with null configuration" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT expect(File.exist?("test.doc")).to be true word = File.read("test.doc") expect(word).to match(/one empty stylesheet/) expect(word).to match(/div\.table_container/) expect(word).not_to match(/word-override/) end it "generates HTML output docs with null configuration from file" do FileUtils.rm_f "spec/assets/iso.doc" FileUtils.rm_f "spec/assets/iso.html" IsoDoc::HtmlConvert.new( { wordstylesheet: "word.css", htmlstylesheet: "html.scss" }, ).convert("spec/assets/iso.xml", nil, false) expect(File.exist?("spec/assets/iso.html")).to be true html = File.read("spec/assets/iso.html") expect(html).to match(/another empty stylesheet/) expect(html).to match(%r{https://use.fontawesome.com}) expect(html).to match(%r{libs/jquery}) expect(html).to include "$('#toggle')" expect(html).not_to match(/CDATA/) end it "generates Headless HTML output docs with null configuration from file" do FileUtils.rm_f "spec/assets/iso.html" IsoDoc::HeadlessHtmlConvert.new( { wordstylesheet: "word.css", htmlstylesheet: "html.scss" }, ).convert("spec/assets/iso.xml", nil, false) expect(File.exist?("spec/assets/iso.headless.html")).to be true html = File.read("spec/assets/iso.headless.html") expect(html).not_to match(/another empty stylesheet/) expect(html).not_to match(%r{https://use.fontawesome.com}) expect(html).not_to match(%r{libs/jquery}) expect(html).not_to match(%r{

These results are based on a study carried out on three different types of kernel.

INPUT html = File.read("test.html") expect(html).to match(/another empty stylesheet/) expect(html).to match(/p \{[^}]*?font-family: Zapf/m) expect(html).to match(/code \{[^}]*?font-family: Consolas/m) expect(html).to match(/h1 \{[^}]*?font-family: Comic Sans/m) expect(html).to match(/p \{[^}]*?font-size: 30pt/m) expect(html).to match(/code \{[^}]*?font-size: 29pt/m) expect(html).to match(/p\.note \{[^}]*?font-size: 28pt/m) expect(html).to match(/aside \{[^}]*?font-size: 27pt/m) expect(html).to match(/an empty html cover page/) expect(html).to match(/an empty html intro page/) expect(html).to match(/This is > a script/) expect(html).to match(/This is > also a script/) expect(html).not_to match(/CDATA/) expect(html).to match(%r{Antaŭparolo}) expect(html).to match(%r{html-override}) end it "generates HTML output docs with default fonts" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new( { htmlstylesheet: "spec/assets/html.scss", htmlcoverpage: "spec/assets/htmlcover.html", htmlintropage: "spec/assets/htmlintro.html", scripts: "spec/assets/scripts.html", i18nyaml: "spec/assets/i18n.yaml", ulstyle: "l1", olstyle: "l2" }, ).convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT html = File.read("test.html") expect(html).to match(/another empty stylesheet/) expect(html).to match(/p \{[^}]*?font-family: Arial/m) expect(html).to match(/code \{[^}]*?font-family: Courier/m) expect(html).to match(/h1 \{[^}]*?font-family: Arial/m) expect(html).to match(/p \{[^}]*?font-size: 1em;/m) expect(html).to match(/code \{[^}]*?font-size: 0.8em/m) expect(html).to match(/p\.note \{[^}]*?font-size: 0.9em/m) expect(html).to match(/aside \{[^}]*?font-size: 0.9em/m) expect(html).to match(/an empty html cover page/) expect(html).to match(/an empty html intro page/) expect(html).to match(/This is > a script/) expect(html).not_to match(/CDATA/) expect(html).to match(%r{Antaŭparolo}) end it "generates Word output docs with complete configuration" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new( { bodyfont: "Zapf", monospacefont: "Consolas", headerfont: "Comic Sans", normalfontsize: "30pt", monospacefontsize: "29pt", smallerfontsize: "28pt", footnotefontsize: "27pt", wordstylesheet: "spec/assets/html.scss", wordstylesheet_override: "spec/assets/word_override.css", standardstylesheet: "spec/assets/std.css", header: "spec/assets/header.html", wordcoverpage: "spec/assets/wordcover.html", wordintropage: "spec/assets/wordintro.html", i18nyaml: "spec/assets/i18n.yaml", ulstyle: "l1", olstyle: "l2" }, ).convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT word = File.read("test.doc") expect(word).to match(/another empty stylesheet/) expect(word).to match(/p \{[^}]*?font-family: Zapf/m) expect(word).to match(/code \{[^}]*?font-family: Consolas/m) expect(word).to match(/h1 \{[^}]*?font-family: Comic Sans/m) expect(word).to match(/p \{[^}]*?font-size: 30pt/m) expect(word).to match(/code \{[^}]*?font-size: 29pt/m) expect(word).to match(/p\.note \{[^}]*?font-size: 28pt/m) expect(word).to match(/aside \{[^}]*?font-size: 27pt/m) expect(word).to match(/a third empty stylesheet/) expect(word) .to match(/Content-Disposition: inline; filename="filelist.xml"/) expect(word).to match(/an empty word cover page/) expect(word).to match(/an empty word intro page/) expect(word).to match(%r{Antaŭparolo}) expect(word).to match(%r{word-override}) end it "generates Word output docs with default fonts" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/html.scss", standardstylesheet: "spec/assets/std.css", header: "spec/assets/header.html", wordcoverpage: "spec/assets/wordcover.html", wordintropage: "spec/assets/wordintro.html", i18nyaml: "spec/assets/i18n.yaml", ulstyle: "l1", olstyle: "l2" }, ).convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT word = File.read("test.doc") expect(word).to match(/another empty stylesheet/) expect(word).to match(/p \{[^}]*?font-family: Arial/m) expect(word).to match(/code \{[^}]*?font-family: Courier/m) expect(word).to match(/h1 \{[^}]*?font-family: Arial/m) expect(word).to match(/p \{[^}]*?font-size: 12pt/m) expect(word).to match(/code \{[^}]*?font-size: 11pt/m) expect(word).to match(/p\.note \{[^}]*?font-size: 10pt/m) expect(word).to match(/aside \{[^}]*?font-size: 9pt/m) expect(word).to match(/a third empty stylesheet/) # expect(word).to match(/test<\/title>/) expect(word) .to match(/Content-Disposition: inline; filename="filelist.xml"/) expect(word).to match(/an empty word cover page/) expect(word).to match(/an empty word intro page/) expect(word).to match(%r{Antaŭparolo</h1>}) end it "converts definition lists to tables for Word" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false) <iso-standard xmlns="http://riboseinc.com/isoxml"> <preface><foreword> <dl> <dt>Term</dt> <dd>Definition</dd> <dt>Term 2</dt> <dd>Definition 2</dd> </dl> </foreword></preface> </iso-standard> INPUT word = File.read("test.doc") .sub(/^.*<div class="WordSection2">/m, '<div class="WordSection2">') .sub(%r{<p class="MsoNormal">\s*<br clear="all" class="section"/>\s*</p>\s*<div class="WordSection3">.*$}m, "") expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT") <div class="WordSection2"> <p class="MsoNormal"><br clear="all" style="mso-special-character:line-break;page-break-before:always"/></p> <div> <h1 class="ForewordTitle">Foreword</h1> <table class="dl"> <tr> <td valign="top" align="left"> <p align="left" style="margin-left:0pt;text-align:left;" class="MsoNormal">Term</p> </td> <td valign="top">Definition</td> </tr> <tr> <td valign="top" align="left"> <p align="left" style="margin-left:0pt;text-align:left;" class="MsoNormal">Term 2</p> </td> <td valign="top">Definition 2</td> </tr> </table> </div> <p class="MsoNormal"> </p> </div> OUTPUT end it "populates Word template with terms reference labels" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false) <iso-standard xmlns="http://riboseinc.com/isoxml"> <sections> <terms id="_terms_and_definitions" obligation="normative"><title>1.<tab/>Terms and Definitions 1.1.paddy

rice retaining its husk after threshing

ISO 7301:2011, Clause 3.1

The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here

INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "") expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")

1.  Terms and Definitions

1.1.

paddy

rice retaining its husk after threshing

[SOURCE: ISO 7301:2011, Clause 3.1, modified — The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here]

OUTPUT end it "populates Word header" do FileUtils.rm_f "test.doc" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", header: "spec/assets/header.html" }, ).convert("test", <<~"INPUT", false) 1000 INPUT word = File.read("test.doc") .sub(%r{^.*Content-ID: }m, "Content-ID: ") .sub(/------=_NextPart.*$/m, "") expect(word).to be_equivalent_to <<~"OUTPUT" Content-ID: Content-Disposition: inline; filename="header.html" Content-Transfer-Encoding: base64 Content-Type: text/html charset="utf-8" Ci8qIGFuIGVtcHR5IGhlYWRlciAqLwoKU1RBUlQgRE9DIElEOiAKICAgICAgICAgICAxMDAwCiAg ICAgICAgIDogRU5EIERPQyBJRAoKRklMRU5BTUU6IHRlc3QKCg== OUTPUT end it "populates Word ToC" do FileUtils.rm_f "test.doc" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", wordintropage: "spec/assets/wordintro.html" }, ).convert("test", <<~"INPUT", false) Clause 4 Introduction<bookmark id="Q"/> to this <image src="spec/assets/rice_image1.png" id="_" mimetype="image/png"/> <fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> </fn> Clause 4.2

A

Formerly denoted as 15 % (m/m).

Clause 4.2.1
INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc"))) .to be_equivalent_to xmlpp(<<~'OUTPUT') OUTPUT end it "populates Word ToC with custom levels" do FileUtils.rm_f "test.doc" IsoDoc::WordConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", wordintropage: "spec/assets/wordintro.html", doctoclevels: 3 }, ).convert("test", <<~"INPUT", false) Clause 4 Introduction<bookmark id="Q"/> to this<fn reference="1"> <p id="_ff27c067-2785-4551-96cf-0a73530ff1e6">Formerly denoted as 15 % (m/m).</p> </fn> Clause 4.2

A

Formerly denoted as 15 % (m/m).

Clause 4.2.1
INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") expect(xmlpp(word.gsub(/_Toc\d\d+/, "_Toc"))) .to be_equivalent_to xmlpp(<<~'OUTPUT') OUTPUT end it "generates HTML output with custom ToC levels function" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new({ htmltoclevels: 3 }) .convert("test", <<~"INPUT", false)

These results are based on a study carried out on three different types of kernel.

INPUT html = File.read("test.html") toclevel = <<~"TOCLEVEL" function toclevel() { return "h1:not(:empty):not(.TermNum):not(.noTOC),h2:not(:empty):not(.TermNum):not(.noTOC),h3:not(:empty):not(.TermNum):not(.noTOC)";} TOCLEVEL expect(html).to include toclevel end it "reorders footnote numbers in HTML" do FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss", wordintropage: "spec/assets/wordintro.html" }, ).convert("test", <<~"INPUT", false) Clause 4

This is a footnote.

Introduction to this<fn reference="2"> Formerly denoted as 15 % (m/m). </fn> Clause 4.2

A

Formerly denoted as 15 % (m/m).

INPUT html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")

Clause 4

1

Introduction to this2

Clause 4.2

A2

OUTPUT end it "moves images in HTML" do FileUtils.rm_f "test.html" FileUtils.rm_rf "test_htmlimages" IsoDoc::HtmlConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false)
Split-it-right sample divider
INPUT html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(`ls test_htmlimages`).to match(/\.png$/) expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword

Split-it-right sample divider

OUTPUT end describe "mathvariant to plain" do context "when `mathvariant` attr equal to `script`" do it "converts mathvariant text chars into associated plain chars" do FileUtils.rm_f "test.html" FileUtils.rm_rf "test_htmlimages" input = <<~INPUT Clause

x = l + 1

INPUT output = <<~OUTPUT

Clause

x = 𝓁 + 1

OUTPUT IsoDoc::HtmlConvert.new({}).convert("test", input, false) html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(html).to(be_equivalent_to(output)) end end context "when complex `mathvariant` combinations" do it "converts mathvariant text chars into associated plain chars" do FileUtils.rm_f "test.html" FileUtils.rm_rf "test_htmlimages" input = <<~INPUT Clause

n n + 1 + x y + z

INPUT output = <<~OUTPUT

Clause

𝗇 𝗻 + 𝟭 + 𝙭 𝘆 + 𝖟

OUTPUT IsoDoc::HtmlConvert.new({}).convert("test", input, false) html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(html).to(be_equivalent_to(output)) end end end it "moves images in HTML with no file suffix" do FileUtils.rm_f "test.html" FileUtils.rm_rf "test_htmlimages" IsoDoc::HtmlConvert.new( { wordstylesheet: "spec/assets/word.css", htmlstylesheet: "spec/assets/html.scss" }, ).convert("test", <<~"INPUT", false)
Split-it-right sample divider
INPUT html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(`ls test_htmlimages`).to match(/\.png$/) expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword

Split-it-right sample divider

OUTPUT end it "moves images in HTML, using relative file location" do FileUtils.rm_f "spec/test.html" FileUtils.rm_rf "spec/test_htmlimages" IsoDoc::HtmlConvert .new(wordstylesheet: "assets/word.css", htmlstylesheet: "assets/html.scss") .convert("spec/test", <<~"INPUT", false)
Split-it-right sample divider
INPUT html = File.read("spec/test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(`ls test_htmlimages`).to match(/\.png$/) expect(xmlpp(html.gsub(/\/[0-9a-f-]+\.png/, "/_.png"))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword

Split-it-right sample divider

OUTPUT end it "encodes images in HTML as data URIs" do FileUtils.rm_f "test.html" FileUtils.rm_rf "test_htmlimages" IsoDoc::HtmlConvert.new(htmlstylesheet: "spec/assets/html.scss", datauriimage: true) .convert("test", <<~"INPUT", false)
Split-it-right sample divider
INPUT html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(xmlpp(html.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"}))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword

Split-it-right sample divider

OUTPUT end it "encodes images in HTML as data URIs, using relative file location" do FileUtils.rm_f "spec/test.html" FileUtils.rm_rf "spec/test_htmlimages" IsoDoc::HtmlConvert.new({ htmlstylesheet: "assets/html.scss", datauriimage: true }) .convert("spec/test", <<~"INPUT", false)
Split-it-right sample divider
INPUT html = File.read("spec/test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(xmlpp(html.gsub(%r{src="data:image/png;base64,[^"]+"}, %{src="data:image/png;base64,_"}))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword

Split-it-right sample divider

OUTPUT end it "processes IsoXML terms for HTML" do FileUtils.rm_f "test.html" FileUtils.rm_f "test.doc" IsoDoc::HtmlConvert.new(options) .convert("test", <<~"INPUT", false) Terms and Definitions 1.1.paddy rice

rice retaining its husk after threshing

Foreign seeds, husks, bran, sand, dust.

  • A
  • A
3.1

The term "cargo rice" is shown as deprecated, and Note 1 to entry is not included here

1.2.paddypaddy rice rough rice cargo rice

rice retaining its husk after threshing

  • A

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

  • A

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

3.1
INPUT expect(File.exist?("test.html")).to be true html = File.read("test.html") expect(html).to match(%r{

1\.1\.

}) expect(html).to match(%r{

1\.2\.

}) end it "processes empty term modifications" do FileUtils.rm_f "test.html" FileUtils.rm_f "test.doc" IsoDoc::HtmlConvert.new(options) .convert("test", <<~"INPUT", false) Terms and Definitions paddy rice

rice retaining its husk after threshing

Foreign seeds, husks, bran, sand, dust.

  • A
  • A
ISO 7301:2011, Clause 3.1

INPUT expect(File.exist?("test.html")).to be true html = File.read("test.html") expect(html).to include '[SOURCE: ISO 7301:2011, Clause 3.1, modified]' end it "creates continuation styles for multiparagraph list items in Word" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options) .convert("test", <<~"INPUT", false)

  • A

    B

    1. C

      D

      E
  1. A1

    B1

    • C1

      D1
      n

      is the number of coating layers

INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT") OUTPUT end it "does not lose HTML escapes in postprocessing" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::HtmlConvert.new(options) .convert("test", <<~"INPUT", false) XML code <xml> & INPUT html = File.read("test.html") .sub(/^.*
/m, '
') .sub(%r{
.*$}m, "
") expect(xmlpp(html)).to be_equivalent_to xmlpp(<<~"OUTPUT")

Foreword


   
  <xml> &

XML code

OUTPUT end it "does not lose HTML escapes in postprocessing (Word)" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options) .convert("test", <<~"INPUT", false) XML code <xml> & INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")


Foreword


   
  <xml> &

XML code

 

OUTPUT end it "propagates example style to paragraphs in postprocessing (Word)" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options).convert("test", <<~"INPUT", false)

ABC

INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")


Foreword

ABC

 

OUTPUT end it "deals with image captions (Word)" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options) .convert("test", <<~"INPUT", false)
Typical arrangement of the far-field scan set-up
INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") .sub(/src="[^"]+"/, 'src="_"') expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")


Foreword

Typical arrangement of the far-field scan set-up

 

OUTPUT end it "deals with empty table titles (Word)" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options) .convert("test", <<~"INPUT", false)

Output wavelength (μm)

Predictive wavelengths
INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") .sub(/src="[^"]+"/, 'src="_"') expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT")


Foreword

Output wavelength ( μm)

Predictive wavelengths

 

OUTPUT end it "propagates alignment of table cells (Word)" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" IsoDoc::WordConvert.new(options) .convert("test", <<~"INPUT", false)

Output wavelength

Output wavelength

Predictive wavelengths

INPUT word = File.read("test.doc") .sub(/^.*
/m, '
') .sub(%r{

\s*
\s*

\s*
.*$}m, "") .sub(/src="[^"]+"/, 'src="_"') expect(xmlpp(word)).to be_equivalent_to xmlpp(<<~"OUTPUT") OUTPUT end it "cleans up boilerplate" do input = <<~INPUT

License

Feedback