require "spec_helper" RSpec.describe IsoDoc do it "processes inline formatting" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

A B C D E F G


INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Foreword

A B C D E F G



OUTPUT end it "processes links" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

example mailto:fred@example.com

INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Foreword

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

OUTPUT end it "processes unrecognised markup" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

example

INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Foreword

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

OUTPUT end it "processes AsciiMath and MathML" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

A X Latex?

INPUT expect(xmlpp(output.sub(/

Foreword

(#(A)#) X Latex?

OUTPUT end it "overrides AsciiMath delimiters" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

A(#((Hello))#)

INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Foreword

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

OUTPUT end it "processes eref types" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true)

A A

1<tab/> Normative references Cereals and cereal products ISO 712 ISO INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Foreword

A A

1  Normative references

ISO 712, Cereals and cereal products

OUTPUT end it "processes eref content" do output = IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true)

1-2-3 1 1 1 1 1 1 a 1 1.5 1 A 7 A

Normative References Cereals and cereal products ISO 712 ISO
INPUT expect(xmlpp(output).sub(%r{.*}m, "")).to be_equivalent_to xmlpp(<<~"OUTPUT")

1-2-3 IEV, 1-2-3 ISO 712 ISO 712 1 ISO 712, Table 1 1 1 ISO 712, Table 1–1 1 1 ISO 712, Clause 1, Table 1 1 a ISO 712, Clause 1 a) 1 ISO 712, Clause 1 1.5 ISO 712, 1.5 1 A ISO 712, Whole of text 7 ISO 712, Prelude 7 A

1<tab/> Normative References Cereals and cereal products ISO 712 ISO
OUTPUT end it "processes concept markup" do input = <<~INPUT

  • term0
  • term1 term
  • term2 w[o]rd Clause #1
  • term3 term
  • term4 word The Aforementioned Citation
  • term5 word 3.1 a
  • term6 word 3.1 b
  • term7 word 3.1 b The Aforementioned Citation
  • term8 word
  • term9 word The IEV database
  • term10 word error!

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 2

  • (Clause 3)
  • term (Clause 3)
  • w[o]rd (Clause #1)
  • term (ISO 712)
  • word (The Aforementioned Citation)
  • word ( 3.1 a ISO 712, 3.1, Figure a)
  • word ( 3.1 b ISO 712, 3.1; Figure b)
  • word ( 3.1 b The Aforementioned Citation )
  • word [term defined in ]
  • word [term defined in The IEV database]
  • word error!

3<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
OUTPUT output = <<~OUTPUT #{HTML_HDR}

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.

ISO 712, Cereals and cereal products

2

3  Clause 1

OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}) .convert("test", presxml, true))).to be_equivalent_to xmlpp(output) end it "processes concept markup by context" do input = <<~INPUT
  • term1 term
  • term1 term
  • term1 term
INPUT presxml = <<~OUTPUT
  • term
1 1.1
  • term ( 1.1 )
  • term
OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(presxml) end it "processes concept attributes" do input = <<~INPUT Clause 1

  • term term
  • term term
  • term term
  • term term
  • term term
  • term term

INPUT presxml = <<~OUTPUT 1<tab/>Clause 1 2

  • term (Clause 1)
  • term (Clause 1)
  • term (Clause 1)
  • term
  • term
  • term

OUTPUT output = <<~OUTPUT #{HTML_HDR}

1  Clause 1

2

OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}) .convert("test", presxml, true))).to be_equivalent_to xmlpp(output) end end