require "spec_helper" RSpec.describe IsoDoc do it "processes section names" do input = <<~INPUT Foreword

This is a preamble

Introduction Introduction Subsection

This is patent boilerplate

Scope

Text

Terms, Definitions, Symbols and Abbreviated Terms Normal Terms Term2
Symbol
Definition
Symbol
Definition
Clause 4 Introduction Clause 4.2
Annex Annex A.1 Annex A.1a An Appendix Appendix subclause Annex Bibliography Normative References Bibliography Bibliography Subsection
INPUT presxml = <<~OUTPUT Foreword

This is a preamble

0<tab/>Introduction 0.1<tab/>Introduction Subsection

This is patent boilerplate

1<tab/>Scope

Text

3<tab/>Terms, Definitions, Symbols and Abbreviated Terms 3.1<tab/>Normal Terms 3.1.1 Term2 3.2
Symbol
Definition
4
Symbol
Definition
5<tab/>Clause 4 5.1<tab/>Introduction 5.2<tab/>Clause 4.2
<strong>Annex A</strong> <br/> (normative) <br/> <br/> <strong>Annex</strong> A.1<tab/>Annex A.1 A.1.1<tab/>Annex A.1a Appendix 1<tab/>An Appendix Appendix 1.1 <tab/> Appendix subclause A.2<tab/>Annex Bibliography 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT #{HTML_HDR}

Foreword

This is a preamble


0  Introduction

0.1  Introduction Subsection

This is patent boilerplate

1  Scope

Text

2  Normative References

3  Terms, Definitions, Symbols and Abbreviated Terms

3.1  Normal Terms

3.1.1

Term2

3.2 

Symbol

Definition

4

Symbol

Definition

5  Clause 4

5.1  Introduction

5.2  Clause 4.2


Annex A
(normative)

Annex

A.1  Annex A.1

A.1.1  Annex A.1a

Appendix 1  An Appendix

Appendix 1.1   Appendix subclause

A.2  Annex Bibliography


Bibliography

Bibliography Subsection

OUTPUT word = <<~OUTPUT

 



Foreword

This is a preamble


0   Introduction

0.1   Introduction Subsection

This is patent boilerplate

 


1   Scope

Text

2   Normative References

3   Terms, Definitions, Symbols and Abbreviated Terms

3.1   Normal Terms

3.1.1

Term2

3.2  

Symbol

Definition

4

Symbol

Definition

5   Clause 4

5.1   Introduction

5.2   Clause 4.2


Annex A
(normative)

Annex

A.1   Annex A.1

A.1.1   Annex A.1a

Appendix 1   An Appendix

Appendix 1.1   Appendix subclause

A.2   Annex Bibliography


Bibliography

Bibliography Subsection


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(html) expect(xmlpp(IsoDoc::Iso::WordConvert.new({}).convert("test", presxml, true) .sub(/^.*.*$}m, ""))).to be_equivalent_to xmlpp(word) end it "processes subclauses with and without titles" do input = <<~INPUT Scope Scope 1 INPUT presxml = <<~OUTPUT 1<tab/>Scope 1.1<tab/>Scope 1 1.2 OUTPUT html = <<~OUTPUT

 


 


1  Scope

1.1  Scope 1

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(html) end it "processes simple terms & definitions" do expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}) .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Terms, Definitions, Symbols and Abbreviated Terms 1.1 Term2 INPUT #{HTML_HDR}

Terms, Definitions, Symbols and Abbreviated Terms

1.1

Term2

OUTPUT end it "processes inline section headers" do output = IsoDoc::Iso::HtmlConvert.new({}).convert("test", <<~"INPUT", true) Clause 4 Introduction Clause 4.2

Hello

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

Clause 4

Introduction

Clause 4.2 

Hello

OUTPUT end it "adds colophon to published standard (Word)" do output = IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true) 60 INPUT expect(xmlpp(output.sub(/^.*.*$}m, ""))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

 


 



OUTPUT end it "does not add colophon to draft standard (Word)" do output = IsoDoc::Iso::WordConvert.new({}).convert("test", <<~"INPUT", true) 30 INPUT expect(xmlpp(output.sub(/^.*.*$}m, ""))) .to be_equivalent_to xmlpp(<<~"OUTPUT")

 


 


OUTPUT end it "processes middle title" do expect(xmlpp(IsoDoc::Iso::HtmlConvert.new({}) .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Introduction Main Title — Title Title Part 17301 INPUT #{HTML_HDR}

Introduction — Main Title — Title —

Part 1:
Title Part

OUTPUT end it "generates an index in English" do input = <<~INPUT en élongé êtreHusserlen allemand Emancipation Emancipationdans la France Emancipationdans la Franceen Bretagne Emancipation zebra Emancipationdans les États-Unis Emancipationdans la Franceà Paris êtreHusserlzebra êtreHusserlEmancipation êtreHusserlzebra Daseinêtre DaseinEmancipation INPUT presxml = <<~OUTPUT en 1 1.1 Index
  • Dasein , see Eman cipation, être
  • élongé, Clause 1
  • Eman cipation, Clause 1 , 1.1
    • dans la France, Clause 1
      • à Paris, 1.1
      • en Bretagne, Clause 1
    • dans les États-Unis, 1.1
  • être
    • Husserl, see zebra, see also Eman cipation, zebra
      • en allemand, Clause 1
  • zebra, 1.1
OUTPUT html = <<~OUTPUT

 


 


Index

OUTPUT expect(xmlpp(strip_guid(IsoDoc::Iso::PresentationXMLConvert.new({}).convert("test", input, true) .gsub(%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 end