require "spec_helper" RSpec.describe IsoDoc do it "cross-references notes in amendments" do output = IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", <<~"INPUT", true) amendment

Scope

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

Widgets

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

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

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

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

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

INPUT expect(xmlpp(output) .sub(%r{.*}m, "")) .to be_equivalent_to xmlpp(<<~"OUTPUT") amendment Amendment

Scope, Note Widgets, 1, Note 1 Widgets, 1, Note 2 A.1, Note A.2, Note 1 A.2, Note 2

Scope NOTE

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

Note

Widgets NOTE 1

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

NOTE 2

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

Note 1 Note 2

<strong>Annex A</strong> <br/><span class="obligation">(informative)</span> A.1 NOTE

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

A.2 NOTE 1

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

NOTE 2

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

OUTPUT end it "cross-references sections" do output = IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", <<~"INPUT", true) amendment Foreword

This is a preamble

Introduction Introduction Subsection Text
Scope

Text

Clause 4 Introduction Clause 4.2
Annex Annex A.1 Annex A.1a An Appendix Normative References Bibliography Bibliography Subsection
INPUT expect(xmlpp(output) .sub(%r{.*}m, "")) .to be_equivalent_to xmlpp(<<~"OUTPUT") amendment Amendment Foreword

This is a preamble 0.1 0.2 Scope [H] [I] [J] [K] [L] Clause 4 Introduction Clause 4.2 Annex A A.1 A.1.1 Annex A, Appendix 1 [R]

Introduction Introduction Subsection Text
Scope

Text

Clause 4 Introduction Clause 4.2
<strong>Annex A</strong> <br/> <span class="obligation">(normative)</span> <br/> <br/> <strong>Annex</strong> A.1 <tab/> Annex A.1 A.1.1 <tab/> Annex A.1a Appendix 1 <tab/> An Appendix Normative References Bibliography Bibliography Subsection
OUTPUT end it "processes section names" do input = <<~INPUT amendment Copyright License Legal Feedback Abstract Foreword

This is a preamble

Introduction Introduction Subsection Dedication Note to reader Acknowledgements
Clause 4 Introduction Clause 4.2 Scope

Text

Annex Annex A.1 Annex A.1a Normative References Bibliography Bibliography Subsection
INPUT presxml = <<~OUTPUT amendment Amendment Copyright License Legal Feedback Abstract Foreword

This is a preamble

Introduction Introduction Subsection Dedication Note to reader Acknowledgements
Clause 4 Introduction Clause 4.2 Scope

Text

<strong>Annex A</strong><br/><span class="obligation">(normative)</span><br/><br/><strong>Annex</strong> A.1<tab/>Annex A.1 A.1.1<tab/>Annex A.1a <strong>Annex B</strong><br/><span class="obligation">(normative)</span> Normative References Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT

 


 


License

Feedback


Abstract


Foreword

This is a preamble


Introduction

Introduction Subsection


Dedication


Note to reader


Acknowledgements

Normative References

Clause 4

Introduction

Clause 4.2

Scope

Text


Annex A
(normative)

Annex

A.1  Annex A.1

A.1.1  Annex A.1a


Annex B
(normative)


Bibliography

Bibliography Subsection

OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true)) .sub(%r{.*}m, "")) .to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end it "processes IsoXML metadata" do c = IsoDoc::Iso::HtmlConvert.new({}) _ = c.convert_init(<<~"INPUT", "test", false) INPUT input = <<~INPUT Introduction — Main Title — Title — Title Part  — Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions Introduction Main Title — Title Title Part Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions Introduction Française — Titre Principal — Part du Titre — Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport Introduction Française Titre Principal Part du Titre Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport ISO/PreNWIP3 17301-1:2016/Amd.1 ISO/PreNWIP3 17301-1:2016/Amd.1(E) ISO/PreNWIP3 17301-1:2016/Amd.1:2017(E) 17301 2016-05-01 International Organization for Standardization ISO International Organization for Standardization ISO 2 2000-01-01 0.3.4 en 10 20 3 2017 International Organization for Standardization ISO amendment TC TC1 SC SC1 WG WG1 SECRETARIAT 1 2 3 17301 New work item proposal international-standard INPUT output = <<~OUTPUT {:accesseddate=>"XXX", :agency=>"ISO", :circulateddate=>"XXX", :confirmeddate=>"XXX", :copieddate=>"XXX", :createddate=>"2016-05-01", :docnumber=>"ISO/PreNWIP3 17301-1:2016/Amd.1", :docnumber_lang=>"ISO/PreNWIP3 17301-1:2016/Amd.1(E)", :docnumber_reference=>"ISO/PreNWIP3 17301-1:2016/Amd.1:2017(E)", :docnumeric=>"17301", :docsubtitle=>"Introduction Française — Titre Principal — Partie 1: Part du Titre", :docsubtitleamd=>"Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport", :docsubtitleamdlabel=>"AMENDMENT 1", :docsubtitlecorrlabel=>"RECTIFICATIF TECHNIQUE 2", :docsubtitleintro=>"Introduction Française", :docsubtitlemain=>"Titre Principal", :docsubtitlepart=>"Part du Titre", :docsubtitlepartlabel=>"Partie 1", :doctitle=>"Introduction — Main Title — Title — Part 1: Title Part", :doctitleamd=>"Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions", :doctitleamdlabel=>"AMENDMENT 1", :doctitlecorrlabel=>"TECHNICAL CORRIGENDUM 2", :doctitleintro=>"Introduction", :doctitlemain=>"Main Title — Title", :doctitlepart=>"Title Part", :doctitlepartlabel=>"Part 1", :doctype=>"Amendment", :doctype_display=>"Amendment", :docyear=>"2017", :draft=>"0.3.4", :draftinfo=>" (draft 0.3.4, 2000-01-01)", :edition=>"2", :editorialgroup=>["A 1", "B 2", "C 3"], :ics=>"1, 2, 3", :implementeddate=>"XXX", :issueddate=>"XXX", :lang=>"en", :obsoleteddate=>"XXX", :publisheddate=>"XXX", :publisher=>"International Organization for Standardization", :receiveddate=>"XXX", :revdate=>"2000-01-01", :revdate_monthyear=>"January 2000", :sc=>"B 2", :script=>"Latn", :secretariat=>"SECRETARIAT", :stage=>"10", :stage_int=>10, :stageabbr=>"NWIP", :statusabbr=>"PreNWIP3", :tc=>"A 1", :transmitteddate=>"XXX", :unchangeddate=>"XXX", :unpublished=>true, :updateddate=>"XXX", :vote_endeddate=>"XXX", :vote_starteddate=>"XXX", :wg=>"C 3"} OUTPUT expect(metadata(c.info(Nokogiri::XML(input), nil))) .to be_equivalent_to output end it "processes IsoXML metadata in French" do c = IsoDoc::Iso::HtmlConvert.new({}) _ = c.convert_init(<<~"INPUT", "test", false) fr INPUT input = <<~INPUT Introduction — Main Title — Title — Title Part  — Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions Introduction Main Title — Title Title Part Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions Introduction Française — Titre Principal — Part du Titre — Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport Introduction Française Titre Principal Part du Titre Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport ISO/PreNWIP3 17301-1:2016/Amd.1 ISO/PreNWIP3 17301-1:2016/Amd.1(E) ISO/PreNWIP3 17301-1:2016/Amd.1:2017(E) 17301 2016-05-01 International Organization for Standardization ISO International Organization for Standardization ISO 2 2000-01-01 0.3.4 fr 10 20 3 2017 International Organization for Standardization ISO amendment Amendment TC TC1 SC SC1 WG WG1 SECRETARIAT 1 2 3 17301 New work item proposal international-standard INPUT output = <<~OUTPUT {:accesseddate=>"XXX", :agency=>"ISO", :circulateddate=>"XXX", :confirmeddate=>"XXX", :copieddate=>"XXX", :createddate=>"2016-05-01", :docnumber=>"ISO/PreNWIP3 17301-1:2016/Amd.1", :docnumber_lang=>"ISO/PreNWIP3 17301-1:2016/Amd.1(E)", :docnumber_reference=>"ISO/PreNWIP3 17301-1:2016/Amd.1:2017(E)", :docnumeric=>"17301", :docsubtitle=>"Introduction — Main Title — Title — Part 1: Title Part", :docsubtitleamd=>"Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions", :docsubtitleamdlabel=>"AMENDMENT 1", :docsubtitlecorrlabel=>"TECHNICAL CORRIGENDUM 2", :docsubtitleintro=>"Introduction", :docsubtitlemain=>"Main Title — Title", :docsubtitlepart=>"Title Part", :docsubtitlepartlabel=>"Part 1", :doctitle=>"Introduction Française — Titre Principal — Partie 1: Part du Titre", :doctitleamd=>"Fraction massique de matière étrangère, riz usiné (non gluant), diviseurs d’échantillon et recommandations relatives aux conditions d’entreposage et de transport", :doctitleamdlabel=>"AMENDMENT 1", :doctitlecorrlabel=>"RECTIFICATIF TECHNIQUE 2", :doctitleintro=>"Introduction Française", :doctitlemain=>"Titre Principal", :doctitlepart=>"Part du Titre", :doctitlepartlabel=>"Partie 1", :doctype=>"Amendment", :doctype_display=>"Amendment", :docyear=>"2017", :draft=>"0.3.4", :draftinfo=>" (brouillon 0.3.4, 2000-01-01)", :edition=>"2", :editorialgroup=>["A 1", "B 2", "C 3"], :ics=>"1, 2, 3", :implementeddate=>"XXX", :issueddate=>"XXX", :lang=>"fr", :obsoleteddate=>"XXX", :publisheddate=>"XXX", :publisher=>"International Organization for Standardization", :receiveddate=>"XXX", :revdate=>"2000-01-01", :revdate_monthyear=>"Janvier 2000", :sc=>"B 2", :script=>"Latn", :secretariat=>"SECRETARIAT", :stage=>"10", :stage_int=>10, :stageabbr=>"NWIP", :statusabbr=>"PreNWIP3", :tc=>"A 1", :transmitteddate=>"XXX", :unchangeddate=>"XXX", :unpublished=>true, :updateddate=>"XXX", :vote_endeddate=>"XXX", :vote_starteddate=>"XXX", :wg=>"C 3"} OUTPUT expect(metadata(c.info(Nokogiri::XML(input), nil))) .to be_equivalent_to output end it "processes middle title" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true) Introduction Main Title — Title Title Part Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions 17301 INPUT expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT") #{HTML_HDR}

Introduction — Main Title — Title —

Part 1:
Title Part

AMENDMENT 1: Mass fraction of extraneous matter, milled rice (nonglutinous), sample dividers and recommendations relating to storage and transport conditions

TECHNICAL CORRIGENDUM 2

OUTPUT end end