require "spec_helper" RSpec.describe IsoDoc do it "processes English" do input = <<~INPUT 60 en international-standard 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 60 International Standard en international-standard International Standard 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/><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 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


Bibliography

Bibliography Subsection

OUTPUT word = <<~WORD

 



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



(normative)

Annex

A.1   Annex A.1

A.1.1   Annex A.1a

Appendix 1   An Appendix


Bibliography

Bibliography Subsection


WORD 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) expect(xmlpp(IsoDoc::Iso::WordConvert.new({}) .convert("test", presxml, true))) .to be_equivalent_to xmlpp(word) end it "defaults to English" do output = IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", <<~"INPUT", true) 60 tlh international-standard 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 expect(xmlpp(output) .sub(%r{.*}m, "")) .to be_equivalent_to xmlpp(<<~"OUTPUT") 60 International Standard tlh international-standard International Standard 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/><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 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT end it "processes French" do input = <<~INPUT 60 fr international-standard 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 60 Norme internationale fr international-standard Norme internationale 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/><span class='obligation'>(normative)</span> <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.gsub(/"en"/, '"fr"')}

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


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::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 Russian" do input = <<~INPUT 60 ru international-standard 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 60 Международный Стандарт ru international-standard Международный Стандарт 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>Дополнение A</strong> <br/><span class='obligation'>(нормативное)</span> <br/> <br/> <strong>Annex</strong> A.1<tab/>Annex A.1 A.1.1<tab/>Annex A.1a Приложение 1<tab/>An Appendix 2<tab/>Normative References Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT #{HTML_HDR.gsub(/"en"/, '"ru"')}

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


Дополнение A
(нормативное)

Annex

A.1  Annex A.1

A.1.1  Annex A.1a

Приложение 1  An Appendix


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 Simplified Chinese" do input = <<~INPUT 60 zh international-standard Foreword

This is a preamble

Introduction Introduction Subsection

This is patent boilerplate

Scope

1 1

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 Cereals and cereal products. ISO 712 Bibliography Bibliography Subsection
INPUT presxml = <<~OUTPUT 60 国际标准 zh international-standard 国际标准 Foreword

This is a preamble

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

This is patent boilerplate

1<tab/>Scope

11ISO 712, 第1–1表

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>附件A</strong> <br/><span class='obligation'>(规范性附录)</span> <br/> <br/> <strong>Annex</strong> A.1<tab/>Annex A.1 A.1.1<tab/>Annex A.1a 附录1<tab/>An Appendix 2<tab/>Normative References Cereals and cereal products. ISO 712 Bibliography Bibliography Subsection
OUTPUT html = <<~OUTPUT #{HTML_HDR.gsub(/"en"/, '"zh"')}

Foreword

This is a preamble


0 Introduction

0.1 Introduction Subsection

This is patent boilerplate

1 Scope

ISO 712, 第1–1表

2 Normative References

ISO 712, Cereals and cereal products.

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


附件A
(规范性附录)

Annex

A.1 Annex A.1

A.1.1 Annex A.1a

附录1 An Appendix


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 "internationalises locality" do input = <<~"INPUT" fr published withdrawn 2 brochure Foreword

7

7

Normative References Cereals and cereal products ISO 712 ISO
INPUT presxml = <<~OUTPUT Foreword

7 ISO 712, Appendice 7

7 ISO 712, Annexe 7

OUTPUT expect(xmlpp(Nokogiri::XML(IsoDoc::Iso::PresentationXMLConvert .new({}).convert("test", input, true)) .at("//xmlns:foreword").to_xml)) .to be_equivalent_to xmlpp(presxml) end end