require "spec_helper" RSpec.describe IsoDoc do it "processes English" do input = <<~INPUT 1 en international-standard true emc 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 presxml = <<~OUTPUT 1 en international-standardNorme internationaleInternational Standard trueNorme horizontaleHorizontal Standard emcPublication fondamentale en CEMBasic EMC Publication 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 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT #{HTML_HDR}

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

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


Bibliography

Bibliography Subsection

OUTPUT expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}) .convert("test", input, true) .sub(%r{.*}m, ""))) .to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end it "defaults to English" do input = <<~INPUT tlh 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 output = <<~OUTPUT tlh 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 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}) .convert("test", input, true) .sub(%r{.*}m, ""))) .to be_equivalent_to xmlpp(output) end it "processes French" do input = <<~INPUT fr international-standard false emc 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 presxml = <<~OUTPUT fr international-standardNorme internationaleInternational Standard false emcPublication fondamentale en CEMBasic EMC Publication 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>Annexe A</strong><br/>(normative)<br/><br/><strong>Annex</strong> A.1<tab/>Annex A.1 A.1.1<tab/>Annex A.1a Appendice 1<tab/>An Appendix 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT #{HTML_HDR.sub(/INTERNATIONAL ELECTROTECHNICAL COMMISSION/, 'COMMISSION ELECTROTECHNIQUE INTERNATIONALE') .gsub(/"en"/, '"fr"')}

AVANT-PROPOS


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

Symbol

Definition

4

Symbol

Definition

5  Clause 4

5.1  Introduction

5.2  Clause 4.2


Annexe A
(normative)

Annex

A.1  Annex A.1

A.1.1  Annex A.1a

Appendice 1  An Appendix


Bibliography

Bibliography Subsection

OUTPUT expect(xmlpp(IsoDoc::Iec::PresentationXMLConvert.new({}) .convert("test", input, true) .sub(%r{.*}m, ""))) .to be_equivalent_to xmlpp(presxml) expect(xmlpp(IsoDoc::Iec::HtmlConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(html) end end