require "spec_helper" RSpec.describe IsoDoc do it "processes Relaton bibliographies" do input = <<~INPUT en

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 [110] International Organization for Standardization Cereals, pulses, milled cereal products, xxxx, oilseeds and animal feeding stuffs Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs ISO 16634:-- (all parts) -- ISO Under preparation. (Stage at the time of publication ISO/DIS 16634) all Cereals and pulses ISO 20483:2013-2014 20132014 International Organization for Standardization Standard No I.C.C 167. Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see ) ICC/167

This is an annotation of ISO 20483:2013-2014

Title 5[5]
Bibliography Chemicals for analytical laboratory use ISBN ISBN Instruments for analytical laboratory use ISSN ISSN

This is an annotation of document ISSN.

This is another annotation of document ISSN.

Water for analytical laboratory use ISO 3696 ISO Standard No I.C.C 167. Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see ) [10] Internet Calendaring and Scheduling Core Object Specification (iCalendar) RFC 10 CitationWorks. 2019. How to cite a reference. [Citn] RFC 20 Internet Calendaring and Scheduling Core Object Specification (iCalendar) RFC 20 Internet Calendaring and Scheduling Core Object Specification (iCalendar) ABC 20
INPUT presxml = <<~PRESXML en

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

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 [110] International Organization for Standardization Cereals, pulses, milled cereal products, xxxx, oilseeds and animal feeding stuffs Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs ISO 16634:-- (all parts) -- ISO Under preparation. (Stage at the time of publication ISO/DIS 16634) all Cereals and pulses ISO 20483:2013-2014 2013 2014 International Organization for Standardization Standard No I.C.C 167 . Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see ) ICC/167 NOTE

This is an annotation of ISO 20483:2013-2014

Title 5 [5]
Bibliography Chemicals for analytical laboratory use [1] ISBN ISBN Instruments for analytical laboratory use [2] ISSN ISSN NOTE

This is an annotation of document ISSN.

NOTE

This is another annotation of document ISSN.

Water for analytical laboratory use [3] ISO 3696 ISO Standard No I.C.C 167 . Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see ) [10] Internet Calendaring and Scheduling Core Object Specification (iCalendar) [4] IETF RFC 10 CitationWorks. 2019. How to cite a reference . [Citn] IETF RFC 20 Internet Calendaring and Scheduling Core Object Specification (iCalendar) [5] IETF RFC 20 Internet Calendaring and Scheduling Core Object Specification (iCalendar) [6] DOI ABC 20
PRESXML html = <<~OUTPUT #{HTML_HDR}

Foreword

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

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.

[110], ISO 712, Cereals and cereal products

ISO 16634:-- (all parts) 1 , Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs

ISO 20483:2013-2014, Cereals and pulses

ICC/167, Standard No I.C.C 167 . Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see http://www.icc.or.at )

NOTE   This is an annotation of ISO 20483:2013-2014

[5], Title 5


Bibliography

[1]  Chemicals for analytical laboratory use

[2]  Instruments for analytical laboratory use

NOTE   This is an annotation of document ISSN.

NOTE   This is another annotation of document ISSN.

[3]  ISO 3696, Water for analytical laboratory use

[10]  Standard No I.C.C 167 . Determination of the protein content in cereal and cereal products for food and animal feeding stuffs according to the Dumas combustion method (see http://www.icc.or.at )

[4]  IETF RFC 10, Internet Calendaring and Scheduling Core Object Specification (iCalendar)

Citn  IETF RFC 20, CitationWorks. 2019. How to cite a reference .

[5]  IETF RFC 20, Internet Calendaring and Scheduling Core Object Specification (iCalendar)

[6]  Internet Calendaring and Scheduling Core Object Specification (iCalendar)

OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true) .sub(%r{.*}m, ""))) .to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end it "processes hidden references sections in Relaton bibliographies" do presxml = <<~PRESXML en

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

PRESXML html = <<~OUTPUT #{HTML_HDR}

Foreword

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end it "processes hidden references sections in Relaton bibliographies" do presxml = <<~PRESXML en

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

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, pulses, milled cereal products, xxxx, oilseeds and animal feeding stuffs Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs ISO 16634:-- (all parts) -- ISO Under preparation. (Stage at the time of publication ISO/DIS 16634) all
PRESXML html = <<~OUTPUT #{HTML_HDR}

Foreword

[110] [1] [2] ISO 16634:-- (all parts) ICC/167 [10] Citn [5]

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 16634:-- (all parts) 1 , Cereals, pulses, milled cereal products, oilseeds and animal feeding stuffs

OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end it "selects the primary identifier" do input = <<~INPUT en

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 IEC 217 International Organization for Standardization
INPUT presxml = <<~PRESXML

IEC 217

PRESXML expect(xmlpp(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true), ).at("//xmlns:foreword").to_xml)) .to be_equivalent_to xmlpp(presxml) end it "selects multiple primary identifiers" do input = <<~INPUT en

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 IEC 217 International Organization for Standardization
INPUT presxml = <<~PRESXML

ISO 712 / IEC 217

PRESXML expect(xmlpp(Nokogiri::XML( IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true), ).at("//xmlns:foreword").to_xml)) .to be_equivalent_to xmlpp(presxml) end end