require "spec_helper" RSpec.describe IsoDoc do it "processes section names" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") 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 Normative References Bibliography Bibliography Subsection
INPUT

 


 



#{IEC_TITLE}

FOREWORD


0  INTRODUCTION

0.1  Introduction Subsection

This is patent boilerplate

#{IEC_TITLE1}

1  Scope

Text

2  Normative references

3  Terms, definitions, symbols and abbreviated terms

3.1  Normal Terms

3.1.1

Term2

3.2  Symbols and abbreviated terms

Symbol

Definition

4  Symbols and abbreviated terms

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


Bibliography

Bibliography Subsection

OUTPUT end it "processes section names (Word)" do expect(xmlpp(IsoDoc::Iec::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*.*$}m, ""))).to be_equivalent_to xmlpp(<<~"OUTPUT") 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 Normative References Bibliography Bibliography Subsection
INPUT


#{IEC_TITLE}

FOREWORD


0  INTRODUCTION

0.1  Introduction Subsection

This is patent boilerplate

 


#{IEC_TITLE1}

1  Scope

Text

2  Normative references

3  Terms, definitions, symbols and abbreviated terms

3.1  Normal Terms

3.1.1

Term2

3.2  Symbols and abbreviated terms

Symbol

Definition

4  Symbols and abbreviated terms

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


Bibliography

Bibliography Subsection


OUTPUT end it "processes subclauses with and without titles" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Scope Scope 1 INPUT #{HTML_HDR}

FOREWORD

#{IEC_TITLE1}

1  Scope

1.1  Scope 1

1.2 

OUTPUT end it "processes simple terms & definitions" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Terms, Definitions, Symbols and Abbreviated Terms Term2 INPUT #{HTML_HDR}

FOREWORD

#{IEC_TITLE1}

1  Terms, Definitions, Symbols and Abbreviated Terms

1.1

Term2

OUTPUT end it "processes inline section headers" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Clause 4 Introduction Clause 4.2 INPUT #{HTML_HDR}

FOREWORD

#{IEC_TITLE1}

1  Clause 4

1.1  Introduction

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


#{IEC_TITLE}

FOREWORD

 


#{IEC_TITLE1}

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


#{IEC_TITLE}

FOREWORD

 


#{IEC_TITLE1}
OUTPUT end it "adds boilerplate to foreword" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") International Standard

Boilerplate

INPUT #{HTML_HDR}

FOREWORD

#{IEC_TITLE1}
OUTPUT end it "does not add boilerplate to foreword in amendments" do expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Amendment

Boilerplate

INPUT #{HTML_HDR}

FOREWORD

#{IEC_TITLE1}
OUTPUT end end