require "spec_helper" RSpec.describe IsoDoc do it "processes prefatory blocks" do input = <<~INPUT abstract introduction note Clause 4 Introduction Clause 4.2

admonition

INPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

 


 


note

abstract


introduction

CAUTION

admonition

Clause 4

Introduction

Clause 4.2 
OUTPUT expect(xmlpp(IsoDoc::WordConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

 


 

note


abstract


introduction

 


CAUTION

admonition

Clause 4

Introduction

Clause 4.2  
OUTPUT end it "processes document with no content" do input = <<~INPUT INPUT output = <<~OUTPUT

 


 


OUTPUT expect(xmlpp(IsoDoc::HtmlConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes section names" do input = <<~"INPUT" Copyright License Legal Feedback Abstract Foreword

This is a preamble

Introduction Introduction Subsection Dedication Note to reader Acknowledgements

Initial note

Initial admonition

Scope

Text

Terms, Definitions, Symbols and Abbreviated Terms Normal Terms Term2 Definitions
Symbol
Definition
Symbols and abbreviated terms
Symbol
Definition
Clause 4 Introduction Clause 4.2
Annex Annex A.1 Annex A.1a Annex Bibliography Normative References Bibliography Bibliography Subsection
INPUT presxml = <<~"PRESXML" Copyright License Legal Feedback Abstract Foreword

This is a preamble

Introduction Introduction Subsection Dedication Note to reader Acknowledgements
NOTE

Initial note

Initial admonition

1.<tab/>Scope

Text

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

License

Feedback


Abstract


Foreword

This is a preamble


Introduction

Introduction Subsection


Dedication


Note to reader


Acknowledgements

NOTE   Initial note

WARNING

Initial admonition

1.  Scope

Text

2.  Normative References

3.  Terms, Definitions, Symbols and Abbreviated Terms

3.1.  Normal Terms

3.1.1.

Term2

3.2.  Definitions

Symbol

Definition

4.  Symbols and abbreviated terms

Symbol

Definition

5.  Clause 4

5.1.  Introduction

5.2.  Clause 4.2

5.3.


Annex A
(normative)

Annex

A.1.  Annex A.1

A.1.1.  Annex A.1a

A.1.2.  Annex Bibliography


Annex B
(normative)


Bibliography

Bibliography Subsection

OUTPUT word = <<~"OUTPUT"

 



Abstract

Variant 1


Foreword

Variant 1

This is a preamble


Introduction

Introduction Subsection

Variant 1


Dedication

Variant 1


Note to reader

Variant 1


Acknowledgements

Variant 1

 


NOTE   Initial note

WARNING

Initial admonition

1.   Scope

Variant 1

Text

2.   Normative References

Variant 1

3.   Terms, Definitions, Symbols and Abbreviated Terms

Variant 1

3.1.   Normal Terms

Variant 1

3.1.1.

Term2

3.2.   Definitions

Variant 1

Symbol

Definition

4.   Symbols and abbreviated terms

Variant 1

Symbol

Definition

5.   Clause 4

Variant 1

5.1.   Introduction

Variant 1

5.2.   Clause 4.2

Variant 1

5.3.


Annex A
(normative)

Annex

Variant 1

A.1.   Annex A.1

Variant 1

A.1.1.   Annex A.1a

Variant 1

A.1.2.   Annex Bibliography

Variant 1


Annex B
(normative)


Bibliography

Bibliography Subsection

Variant 1

OUTPUT presxml = IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true) 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 section names suppressing section numbering" do input = <<~INPUT Foreword

This is a preamble

Introduction Introduction Subsection
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 Normative References Bibliography Bibliography Subsection
INPUT output = <<~OUTPUT Foreword

This is a preamble

Introduction Introduction Subsection
Scope

Text

Terms, Definitions, Symbols and Abbreviated Terms Normal Terms 3.1.1. Term2
Symbol
Definition
Symbol
Definition
Clause 4 Introduction Clause 4.2
<strong>Annex A</strong> <br/> (normative) <br/> <br/> <strong>Annex</strong> Annex A.1 Annex A.1a Normative References Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true }) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes section titles without ID" do input = <<~INPUT Introduction Introduction Subsection INPUT output = <<~OUTPUT Introduction Introduction Subsection OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert .new({ suppressheadingnumbers: true }) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes simple terms & definitions" do input = <<~"INPUT" Terms, Definitions, Symbols and Abbreviated Terms Term2 INPUT presxml = <<~"OUTPUT" 1.<tab/>Terms, Definitions, Symbols and Abbreviated Terms 1.1. Term2 OUTPUT html = <<~"OUTPUT" #{HTML_HDR}

1.  Terms, Definitions, Symbols and Abbreviated Terms

1.1.

Term2

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 inline section headers" do input = <<~"INPUT" Clause 4 Introduction Clause 4.2

ABC

INPUT presxml = <<~"PRESXML" 1.<tab/>Clause 4 1.1.<tab/>Introduction 1.2.<tab/>Clause 4.2

ABC

PRESXML output = <<~"OUTPUT" #{HTML_HDR}

1.  Clause 4

1.1.  Introduction

1.2.  Clause 4.2 

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 inline section headers with suppressed heading numbering" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({ suppressheadingnumbers: true }) .convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Clause 4 Introduction Clause 4.2 INPUT Clause 4 Introduction Clause 4.2 OUTPUT end it "processes sections without titles" do input = <<~INPUT Intro INPUT output = <<~OUTPUT Intro 1. 1.1. 1.2. OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "processes clauses containing normative references" do input = <<~INPUT Bibliography Bibliography Subsection 1 Bibliography Subsection 2 First References Normative References 1 Normative References 2 INPUT presxml = <<~OUTPUT Bibliography Bibliography Subsection 1 Bibliography Subsection 2 1.<tab/>First References 1.1.<tab/>Normative References 1 1.2.<tab/>Normative References 2 OUTPUT html = <<~OUTPUT #{HTML_HDR}

1.  First References

1.1.  Normative References 1

1.2.  Normative References 2


Bibliography

Bibliography Subsection 1

Bibliography Subsection 2

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 annexes containing one, or more than one special sections" do input = <<~INPUT Glossary Glossary Glossary Term Collection Term Term Collection 2 Term Glossary Term Collection Term References INPUT presxml = <<~OUTPUT <strong>Annex A</strong> <br/> (normative) <br/> <br/> <strong>Glossary</strong> A. A.1. Glossary <strong>Annex B</strong> <br/> (normative) <br/> <br/> <strong>Glossary</strong> B.1. <tab/> Term Collection B.1.1. Term B.2. <tab/> Term Collection 2 B.2.1. Term <strong>Annex C</strong> <br/> (normative) <br/> <br/> <strong>Glossary</strong> C.1. <tab/> Term Collection C.1.1. Term C.2. <tab/> References OUTPUT expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(presxml) end end