require "spec_helper" RSpec.describe IsoDoc do it "droplocs xrefs" do input = <<~INPUT

This is and . This is and .

INPUT output = <<~OUTPUT 1. 1 2.

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

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert .new({ i18nyaml: "spec/assets/i18n.yaml" }) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes inline formatting" do input = <<~INPUT

A B C D E F G I


J

INPUT html = <<~OUTPUT

Foreword

A B C D E F G I




J

OUTPUT doc = <<~OUTPUT

Foreword

A B C D E F G I




J

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true)) .sub(/^.*

.*$}m, "")) .to be_equivalent_to xmlpp(html) expect(xmlpp(IsoDoc::WordConvert.new({}) .convert("test", input, true)) .sub(/^.*

.*$}m, "")) .to be_equivalent_to xmlpp(doc) end it "ignores index entries" do input = <<~INPUT

Index
INPUT output = <<~OUTPUT

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes concept markup" do input = <<~INPUT

  • term
  • term term
  • term w[o]rd Clause #1
  • term term
  • term word The Aforementioned Citation
  • term word 3.1 a
  • term word 3.1 b
  • term word 3.1 b The Aforementioned Citation
  • term word
  • term word The IEV database
  • 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

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

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

Foreword

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.  Clause 1

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(output) end it "processes concept attributes" do input = <<~INPUT

  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • termterm,
  • error!
  • CV_DiscreteCoverage CV_DiscreteCoverage

Clause 1
INPUT presxml = <<~OUTPUT

  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • term,
  • term,
  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • term [term defined in Clause 1],
  • error!
  • CV_DiscreteCoverage

1.<tab/>Clause 1
OUTPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

1.  Clause 1

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(output) end it "processes concept markup for symbols" do input = <<~INPUT

  • term ISO

ISO
xyz
IEC
abc
INPUT presxml = <<~OUTPUT

  • ISO

1.
ISO
xyz
IEC
abc
OUTPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

  • ISO

1.

ISO

xyz

IEC

abc
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(output) end it "processes related terms" do input = <<~INPUT Terms and definitions Second Term Field Usage Info 1 Definition 1 First Designation Fifth Designation neuter Definition 2 INPUT output = <<~OUTPUT 1.<tab/>Terms and definitions 1.1. Second Term, <Field, Usage Info 1> Definition 1 1.2. First Designation

CONTRAST: Fifth Designation, n (Clause 1.1)

Definition 2
OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes embedded inline formatting" do input = <<~INPUT

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

INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

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

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

alttext

INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

alttext

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

example example mailto:fred@example.com

INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

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

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

example example

INPUT html = <<~OUTPUT

Foreword

http://example.com example example

OUTPUT doc = <<~OUTPUT

Foreword

http://example.com example example

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true)) .sub(/^.*

.*$}m, "")) .to be_equivalent_to xmlpp(html) expect(xmlpp(IsoDoc::WordConvert.new({}) .convert("test", input, true)) .sub(/^.*

.*$}m, "")) .to be_equivalent_to xmlpp(doc) end it "processes unrecognised markup" do input = <<~INPUT

example

INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

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

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

<A> X Latex?

INPUT output = <<~OUTPUT #{HTML_HDR.sub(/

Foreword

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

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true).sub(/

A (#((Hello))#)

INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

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

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "duplicates MathML with AsciiMath" do input = <<~INPUT

( x + y ) 2

INPUT output = <<~OUTPUT

( x + y ) 2 ( x + y )^2

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true) .gsub("", ""))) .to be_equivalent_to xmlpp(output) end it "overrides duplication of MathML with AsciiMath" do input = <<~INPUT

( x + y ) 2

INPUT output = <<~OUTPUT

( x + y ) 2

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert .new({ suppressasciimathdup: "true" }) .convert("test", input, true) .gsub("", ""))) .to be_equivalent_to xmlpp(output) end it "processes eref types" do input = <<~INPUT

A A

Normative References Cereals and cereal products ISO 712 ISO
INPUT output = <<~OUTPUT #{HTML_HDR}

Foreword

A A

Normative References

ISO 712, Cereals and cereal products

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

1 1 11 11 11 1 1.5 1A 7 7 A 1 11 11 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 and 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 7ISO 712, URI 7 A 1ISO 712 11ISO 712, Clause 1 11ISO 712, 1 11ISO 712, clause 1

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

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 Cereals and cereal products spec/assets/iso714.svg ISO 714 ISO
INPUT presxml = <<~OUTPUT

ISO 712 ISO 712 1 ISO 713, Table 1 1ISO 713, Table 1 11ISO 713, Table 1 and 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 ISO 714

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 Cereals and cereal products spec/assets/iso714.svg ISO 714 ISO
OUTPUT html = <<~OUTPUT #{HTML_HDR}

1.  Normative References

ISO 712, Cereals and cereal products

ISO 713, Cereals and cereal products

ISO 714, Cereals and cereal products

OUTPUT word = <<~OUTPUT

 



1.   Normative References

ISO 712, Cereals and cereal products

ISO 713, Cereals and cereal products

ISO 714, 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 eref content pointing to hidden bibliographic entries" do input = <<~INPUT

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