require "spec_helper" RSpec.describe IsoDoc do it "droplocs xrefs" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

This is and . This is and .

INPUT 1. 1 2.

This is klaŭzo 1 and klaŭzo 1, Formula (1) . This is 1 and (1) .

OUTPUT end it "processes inline formatting" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

A B C D E F G I


INPUT #{HTML_HDR}

Foreword

A B C D E F G I




OUTPUT end it "processes inline formatting (Word)" do expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

A B C D E F G I


INPUT #{WORD_HDR}

A B C D E F G I




OUTPUT end it "ignores index entries" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

INPUT #{HTML_HDR}

Foreword

OUTPUT end it "processes concept markup" do input = <<~INPUT

Clause 1 Normative References

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Cereals or cereal products Cereals and cereal products ISO 712 International Organization for Standardization
INPUT presxml = <<~OUTPUT

  • Clause 2
  • w[o]rd
  • ISO 712
  • word
  • 3.1 a ISO 712, Clause 3.1, Figure a
  • 3.1 b ISO 712, Clause 3.1; Figure b
  • 3.1 b word
  • [term defined in ]
  • word word

2. <tab/> Clause 1 1. <tab/> Normative References

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Cereals or cereal products Cereals and cereal products ISO 712 International Organization for Standardization
end it "processes embedded inline formatting" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

< Requirement /req/core/http Requirement /req/core/http

INPUT #{HTML_HDR}

Foreword

< B Requirement /req/core/http Requirement /req/core/http

OUTPUT end it "processes inline images" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

alttext

INPUT #{HTML_HDR}

Foreword

alttext

OUTPUT end it "processes links" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

example example mailto:fred@example.com

INPUT #{HTML_HDR}

Foreword

http://example.com example example fred@example.com mailto:fred@example.com

OUTPUT end it "processes unrecognised markup" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

example

INPUT #{HTML_HDR}

Foreword

<barry fred="http://example.com">example</barry>

OUTPUT end it "processes AsciiMath and MathML" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true).sub(/

<A> X Latex?

INPUT #{HTML_HDR.sub(/

Foreword

(#(<A>)#) X Latex?

OUTPUT end it "overrides AsciiMath delimiters" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

A (#((Hello))#)

INPUT #{HTML_HDR}

Foreword

(#(((A)#))) (#((Hello))#)

OUTPUT end it "processes eref types" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

A A

Normative References Cereals and cereal products ISO 712 ISO INPUT #{HTML_HDR}

Foreword

A A

Normative References

ISO 712, Cereals and cereal products

OUTPUT end it "processes eref content" do input = <<~INPUT

1 1 11 11 11 1 1.5 1A 7 A 1 11

Normative References Cereals and cereal products ISO 712 ISO
INPUT presxml = <<~OUTPUT

ISO 712 ISO 712 1ISO 712, Table 1 1ISO 712, Table 1 11ISO 712, Table 1; Clause 1 11ISO 712, Table 1–1 11ISO 712, Clause 1, Table 1 1ISO 712, Clause 1 1.5ISO 712, Clause 1.5 1A ISO 712, Whole of text 7ISO 712, Prelude 7 A 1ISO 712 11ISO 712, Clause 1

1.<tab/>Normative References Cereals and cereal products ISO 712 ISO
OUTPUT html = <<~OUTPUT #{HTML_HDR}

Foreword

ISO 712 ISO 712 ISO 712, Table 1 ISO 712, Table 1 ISO 712, Table 1; Clause 1 ISO 712, Table 1–1 ISO 712, Clause 1, Table 1 ISO 712, Clause 1 ISO 712, Clause 1.5 A ISO 712, Whole of text ISO 712, Prelude 7 A ISO 712 ISO 712, Clause 1

1.  Normative References

ISO 712, Cereals and cereal products

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html) end it "processes eref content pointing to reference with citation URL" do input = <<~INPUT

1 1 11 11 11 1 1.5 1A 7 A xyz xyz1

Normative References Cereals and cereal products http://www.example.com ISO 712 ISO Cereals and cereal products spec/assets/iso713 ISO 713 ISO
INPUT presxml = <<~OUTPUT

ISO 712 ISO 712 1 ISO 713, Table 1 1ISO 713, Table 1 11ISO 713, Table 1; Clause 1 1 1 ISO 713, Table 1–1 11ISO 713, Clause 1, Table 1 1 ISO 713, Clause 1 1.5 ISO 713, Clause 1.5 1 A ISO 713, Whole of text 7 ISO 713, Prelude 7 A xyzISO 713 xyz1ISO 713, Clause 1

1.<tab/>Normative References Cereals and cereal products http://www.example.com ISO 712 ISO Cereals and cereal products spec/assets/iso713 ISO 713 ISO
OUTPUT html = <<~OUTPUT #{HTML_HDR}

Foreword

ISO 712 ISO 712 ISO 713, Table 1 ISO 713, Table 1 ISO 713, Table 1; Clause 1 ISO 713, Table 1–1 ISO 713, Clause 1, Table 1 ISO 713, Clause 1 ISO 713, Clause 1.5 A ISO 713, Whole of text ISO 713, Prelude 7 A ISO 713 ISO 713, Clause 1

1.  Normative References

ISO 712, Cereals and cereal products

ISO 713, Cereals and cereal products

OUTPUT word = <<~OUTPUT

 



1.   Normative References

ISO 712, Cereals and cereal products

ISO 713, Cereals and cereal products

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", input, true))).to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(html) expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", presxml, true))).to be_equivalent_to xmlpp(word) end it "processes variant" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true).sub(%r{.*}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT") en <variant lang="en" script="Latn">ABC</variant><variant lang="fr" script="Latn">DEF</variant> <variant lang="en" script="Grek">ABC</variant><variant lang="fr" script="Grek">DEF</variant> <variant lang="en">ABC</variant><variant lang="fr">DEF</variant> <variant lang="de" script="Latn">GHI</variant><variant lang="es" script="Latn">JKL</variant> <variant lang="fr" script="Latn">ABC</variant><variant lang="en" script="Latn">DEF</variant> <variant lang="fr" script="Grek">ABC</variant><variant lang="en" script="Grek">DEF</variant> <variant lang="fr">ABC</variant><variant lang="en">DEF</variant>

A BC D EF

INPUT en ABC ABC/DEF ABC GHI/JKL DEF ABC/DEF DEF

A B D E

OUTPUT end it "cases xrefs" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({i18nyaml: "spec/assets/i18n.yaml"}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

This is and . This is and . This is and . is clause initial.
is too.

is also.

INPUT 1. Tabelo 1
2.

This is klaŭzo 1 and tabelo 1 . This is Klaŭzo 1 and tabelo 1 . This is klaŭzo 1 and Tabelo 1 . Klaŭzo 1 is clause initial.
Klaŭzo 1 is too.

Klaŭzo 1 is also.

OUTPUT end end