require "spec_helper" RSpec.describe Asciidoctor::Standoc do it "processes sections" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} .Foreword Text [abstract] == Abstract Text == Introduction === Introduction Subsection == Acknowledgements [.preface] == Dedication == Scope Text [bibliography] == Normative References == Terms and Definitions === Term1 == Terms, Definitions, Symbols and Abbreviated Terms [.boilerplate] === Boilerplate Boilerplate text [.nonterm] === Introduction ==== Intro 1 === Intro 2 [.nonterm] ==== Intro 3 === Intro 4 ==== Intro 5 ===== Term1 === Normal Terms ==== Term2 === Symbols and Abbreviated Terms [.nonterm] ==== General ==== Symbols == Abbreviated Terms == Clause 4 === Introduction === Clause 4.2 == Terms and Definitions [appendix] == Annex === Annex A.1 [bibliography] == Bibliography === Bibliography Subsection [index] == Index This is an index [index,type=thematic] == Thematic Index INPUT output = <<~OUTPUT #{BLANK_HDR.sub(//, '

Text

')} Abstract

Text

Foreword

Text

Introduction Introduction Subsection Dedication Acknowledgements
Scope

Text

Terms and definitions

For the purposes of this document, the following terms and definitions apply.

Term1
Terms, definitions, symbols and abbreviated terms

Boilerplate text

Introduction Intro 1 Intro 2 Intro 3 Intro 4 Intro 5 Term1 Normal Terms Term2 Symbols and abbreviated terms General Symbols
Abbreviated terms Clause 4 Introduction Clause 4.2 Terms and Definitions
Annex Annex A.1 Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
Index

This is an index

Thematic Index OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes sections with number attributes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [number=1bis] == Scope Text [number=2bis] == Normative References [number=3bis] == Terms and Definitions [number=4bis] === Term1 [number=5bis] == Terms, Definitions, Symbols and Abbreviated Terms [.nonterm,number=6bis] === Introduction [number=7bis] ==== Intro 1 [number=8bis] === Intro 2 [number=9bis] === Symbols and Abbreviated Terms [.nonterm,number=10bis] ==== General [number=11bis] ==== Symbols [number=12bis] == Abbreviated Terms [number=13bis] == Clause 4 [number=14bis] === Introduction [number=15bis] === Clause 4.2 [number=16bis] == Terms and Definitions [appendix,number=17bis] == Annex [number=18bis] === Annex A.1 [bibliography,number=19bis] == Bibliography [number=20bis] === Bibliography Subsection INPUT output = <<~OUTPUT #{BLANK_HDR} Scope

Text

Terms and definitions

For the purposes of this document, the following terms and definitions apply.

Term1
Terms, definitions, symbols and abbreviated terms

For the purposes of this document, the following terms and definitions apply.

Introduction Intro 1 Intro 2 Symbols and abbreviated terms General Symbols
Abbreviated terms Clause 4 Introduction Clause 4.2 Terms and Definitions
Annex Annex A.1 Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes sections with language and script attributes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [language=en,script=Latn] == Foreword Text [abstract,language=en,script=Latn] == Abstract Text [language=en,script=Latn] == Introduction [language=en,script=Latn] === Introduction Subsection [language=en,script=Latn] == Acknowledgements [.preface] [language=en,script=Latn] == Dedication [language=en,script=Latn] == Scope Text [language=en,script=Latn] == Normative References [language=en,script=Latn] == Terms and Definitions [language=en,script=Latn] === Term1 [language=en,script=Latn] == Terms, Definitions, Symbols and Abbreviated Terms [.nonterm] [language=en,script=Latn] === Introduction ==== Intro 1 [language=en,script=Latn] === Intro 2 [.nonterm] [language=en,script=Latn] ==== Intro 3 [language=en,script=Latn] === Intro 4 [language=en,script=Latn] ==== Intro 5 ===== Term1 [language=en,script=Latn] === Normal Terms ==== Term2 [language=en,script=Latn] === Symbols and Abbreviated Terms [.nonterm] [language=en,script=Latn] ==== General ==== Symbols [language=en,script=Latn] == Abbreviated Terms [language=en,script=Latn] == Clause 4 [language=en,script=Latn] === Introduction [language=en,script=Latn] === Clause 4.2 [language=en,script=Latn] == Terms and Definitions [appendix,language=en,script=Latn] == Annex [language=en,script=Latn] === Annex A.1 [language=en,script=Latn] == Bibliography [language=en,script=Latn] === Bibliography Subsection INPUT output = <<~OUTPUT #{BLANK_HDR.sub(//, '

Text

')} Abstract

Text

Foreword

Text

Introduction Introduction Subsection Dedication Acknowledgements
Scope

Text

Terms and definitions

For the purposes of this document, the following terms and definitions apply.

Term1
Terms, definitions, symbols and abbreviated terms

For the purposes of this document, the following terms and definitions apply.

Introduction Intro 1 Intro 2 Intro 3 Intro 4 Intro 5 Term1 Normal Terms Term2 Symbols and abbreviated terms General Symbols
Abbreviated terms Clause 4 Introduction Clause 4.2 Terms and Definitions
Annex Annex A.1 Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes sections with title and type attributes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} .Foreword Text [abstract] == Περίληψη Text [heading=introduction] == Εισαγωγή === Introduction Subsection [heading=acknowledgements] == Ευχαριστίες [heading=normative references] == Κανονιστικές Παραπομπές [heading=terms and definitions] == Όροι και Ορισμοί === Term1 [heading="terms, definitions, symbols and abbreviated terms"] == Όροι, Ορισμοί, Σύμβολα και Συντομογραφίες === Normal Terms ==== Term2 [heading=symbols] === Σύμβολα και Συντομογραφίες [heading=abbreviated terms] == Σύμβολα και Συντομογραφίες [type=ABC] == Clause 4 [type=DEF] === Introduction === Clause 4.2 [appendix] == Annex === Annex A.1 [heading=bibliography] == Βιβλιογραφία === Bibliography Subsection INPUT output = <<~OUTPUT #{BLANK_HDR.sub(//, '

Text

')} Abstract

Text

Foreword

Text

Introduction Introduction Subsection Acknowledgements
Terms and definitions

For the purposes of this document, the following terms and definitions apply.

Term1
Terms, definitions and symbols

For the purposes of this document, the following terms and definitions apply.

Normal Terms Term2 Symbols
Abbreviated terms Clause 4 Introduction Clause 4.2
Annex Annex A.1 Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "varies terms & symbols title" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [heading="terms, definitions, symbols and abbreviated terms"] == Terms, Definitions, Symbols Section === Term === Symbols INPUT output = <<~OUTPUT #{BLANK_HDR} Terms, definitions and symbols

For the purposes of this document, the following terms and definitions apply.

Term Symbols
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "varies terms & abbreviated terms title" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [heading="terms, definitions, symbols and abbreviated terms"] == Terms, Definitions, Abbreviated Terms Section === Term [heading="abbreviated terms"] === Symbols INPUT output = <<~OUTPUT #{BLANK_HDR} Terms, definitions and abbreviated terms

For the purposes of this document, the following terms and definitions apply.

Term Abbreviated terms
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "varies terms symbols & abbreviated terms title" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [heading="terms, definitions, symbols and abbreviated terms"] == Terms, Definitions, Abbreviated Terms Section === Term === Abbreviated Terms === Symbols INPUT output = <<~OUTPUT #{BLANK_HDR} Terms, definitions, symbols and abbreviated terms

For the purposes of this document, the following terms and definitions apply.

Term Abbreviated terms Symbols
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes section obligations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [obligation=informative] == Clause 1 === Clause 1a [obligation=normative] == Clause 2 [appendix,obligation=informative] == Annex INPUT output = <<~OUTPUT #{BLANK_HDR} Clause 1 Clause 1a Clause 2 Annex OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes inline headers" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Clause 1 [%inline-header] === Clause 1a [appendix] == Annex A [%inline-header] === Clause Aa INPUT output = <<~OUTPUT #{BLANK_HDR} Clause 1 Clause 1a Annex A Clause Aa OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes blank headers" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Clause 1 === {blank} INPUT output = <<~OUTPUT #{BLANK_HDR} Clause 1 OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes terminal nodes in terms with term subsection names" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms, definitions, symbols and abbreviated terms === Terms and definitions === Symbols INPUT output = <<~OUTPUT #{BLANK_HDR} Terms, definitions and symbols

No terms and definitions are listed in this document.

Terms and definitions Symbols
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes terms & definitions with external source" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} Foreword [source="iso1234,iso5678"] == Terms and Definitions === Term1 INPUT output = <<~OUTPUT #{BLANK_HDR} Foreword

Foreword

Terms and definitions

For the purposes of this document, the terms and definitions given in and and the following apply.

Term1
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes empty terms & definitions" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} Foreword == Terms and Definitions INPUT output = <<~OUTPUT #{BLANK_HDR} Foreword

Foreword

Terms and definitions

No terms and definitions are listed in this document.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes empty terms & definitions with external source" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} Foreword [source="iso1234,iso5678"] == Terms and Definitions INPUT output = <<~OUTPUT #{BLANK_HDR} Foreword

Foreword

Terms and definitions

For the purposes of this document, the terms and definitions given in and apply.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes term document sources in French" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :language: fr Foreword [source="iso1234,iso5678"] == Terms and Definitions INPUT output = <<~OUTPUT #{BLANK_HDR.sub(%r{en}, 'fr')} Avant-propos

Foreword

Terms et définitions

Pour les besoins du présent document, les termes et définitions de et s’appliquent.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes term document sources in Chinese" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :language: zh :script: Hans Foreword [source="iso1234,iso5678"] == Terms and Definitions INPUT output = <<~OUTPUT #{BLANK_HDR.sub(%r{en}, 'zh').sub(%r{}, '')} 前言

Foreword

术语和定义

界定的术语和定义适用于本文件。

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "warn about external source for terms & definitions that does not point anywhere" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [source="iso712"] == Terms and Definitions === Term2 INPUT expect { Asciidoctor.convert(input, *OPTIONS) } .to output(/not referenced/).to_stderr end it "treats terminal terms subclause named as terms clause as a normal clause" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [[tda]] == Terms, definitions, symbols and abbreviations [[terms]] === Terms and definitions === Symbols INPUT output = <<~OUTPUT #{BLANK_HDR} Terms, definitions and symbols

No terms and definitions are listed in this document.

Terms and definitions Symbols
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "treats non-terminal terms subclause named as terms clause as a terms clause" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Scope [[tda]] == Terms, definitions, symbols and abbreviations [[terms]] === Terms and definitions [[terms-concepts]] ==== Basic concepts [[term-date]] ===== date _time_ (<>) on the _calendar_ (<>) _time scale_ (<>) INPUT output = <<~OUTPUT #{BLANK_HDR} Scope Terms and definitions

For the purposes of this document, the following terms and definitions apply.

Terms and definitions Basic concepts date

time ( ) on the calendar ( ) time scale ( )

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "leaves alone special titles in preface or appendix" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [.preface] [[t1]] == Terms and definitions [[t2]] === Term1 [appendix,language=fr] [[sym]] == Symbols and abbreviated terms [.appendix] [[app]] [bibliography] == Normative Reference INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions Term1 Symbols and abbreviated terms Normative Reference OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "recognises special titles despite following indexterms" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Scope (((indexterm))) INPUT output = <<~OUTPUT #{BLANK_HDR} Scope OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end end