require "spec_helper" RSpec.describe IsoDoc do it "cross-references external documents in Presentation XML" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

a#b

OUTPUT end it "cross-references external documents in HTML" do expect(xmlpp(IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

a#b

Foreword

a#b

OUTPUT end it "cross-references external documents in DOC" do expect(xmlpp(IsoDoc::WordConvert.new({}).convert("test", <<~"INPUT", true).sub(/^.*

/m, '
').sub(%r{
.*$}m, "
"))).to be_equivalent_to xmlpp(<<~"OUTPUT")

a#b

INPUT


Foreword

a#b

OUTPUT end it "warns of missing crossreference" do expect { IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true) }.to output(/No label has been processed for ID N1/).to_stderr

INPUT end it "does not warn of missing crossreference if text is supplied" do expect { IsoDoc::HtmlConvert.new({}).convert("test", <<~"INPUT", true) }.not_to output(/No label has been processed for ID N1/).to_stderr

abc INPUT end it "cross-references notes" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

These results are based on a study carried out on three different types of kernel.

Preparatory

These results are based on a study carried out on three different types of kernel.

Scope

These results are based on a study carried out on three different types of kernel.

Widgets

These results are based on a study carried out on three different types of kernel.

These results are based on a study carried out on three different types of kernel.

These results are based on a study carried out on three different types of kernel.

These results are based on a study carried out on three different types of kernel.

These results are based on a study carried out on three different types of kernel.

INPUT

Introduction, Note Preparatory, Note Clause 1, Note Clause 3.1, Note 1 Clause 3.1, Note 2 Annex A.1, Note Annex A.2, Note 1 Annex A.2, Note 2

NOTE

These results are based on a study carried out on three different types of kernel.

Preparatory NOTE

These results are based on a study carried out on three different types of kernel.

1. <tab/> Scope NOTE

These results are based on a study carried out on three different types of kernel.

Note

2. 3. <tab/> Widgets 3.1. NOTE 1

These results are based on a study carried out on three different types of kernel.

NOTE 2

These results are based on a study carried out on three different types of kernel.

Note 1 Note 2

<strong>Annex A</strong> <br/> (informative) A.1. NOTE

These results are based on a study carried out on three different types of kernel.

A.2. NOTE 1

These results are based on a study carried out on three different types of kernel.

NOTE 2

These results are based on a study carried out on three different types of kernel.

OUTPUT end it "cross-references figures" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Split-it-right sample divider
Preparatory
Split-it-right sample divider
Scope
Split-it-right sample divider

Widgets
Split-it-right sample divider

pseudocode

Source! Code! A B C A B C
Split-it-right sample divider

Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Source! Code! A B C
INPUT

Figure 1 Figure (??) Figure 2 Figure 3 Figure 4 Figure 5 Figure 6 [note51] Figure A.1 Figure (??) Figure A.2 Figure A.3

Figure 1 — Split-it-right sample divider
Preparatory
Split-it-right sample divider
1. <tab/> Scope
Figure 2 — Split-it-right sample divider

Figure 2

2. 3. <tab/> Widgets 3.1.
Figure 3 — Split-it-right sample divider
Figure 4

pseudocode

Figure 5 — Source! Code! A B C EXAMPLE A B C
Figure 6 — Split-it-right sample divider

Figure 3 Figure 6

<strong>Annex A</strong> <br/> (informative) A.1.
Figure A.1 — Split-it-right sample divider
A.2.
Split-it-right sample divider
Figure A.2 — Split-it-right sample divider
Figure A.3 — Source! Code! A B C
OUTPUT end it "cross-references subfigures" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Scope Widgets
Split-it-right sample divider
Split-it-right sample divider

Split-it-right sample divider
Split-it-right sample divider
INPUT

Figure 1 Figure 1-1 Figure 1-2 Figure A.1 Figure A.1-1 Figure A.1-2

1. <tab/> Scope 2. 3. <tab/> Widgets 3.1.
Figure 1-1 — Split-it-right sample divider
Figure 1-2 — Split-it-right sample divider

Figure 1-1 Figure 1-2

<strong>Annex A</strong> <br/> (informative) A.1. A.2.
Figure A.1-1 — Split-it-right sample divider
Figure A.1-2 — Split-it-right sample divider
OUTPUT end it "cross-references examples" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Hello

Preparatory

Hello

Scope

Hello

Widgets

Hello

Hello

Hello

Hello

Hello

INPUT

Introduction, Example Preparatory, Example (??) Clause 1, Example Clause 3.1, Example 1 Clause 3.1, Example (??) Annex A.1, Example Annex A.2, Example (??) Annex A.2, Example 1

EXAMPLE

Hello

Preparatory EXAMPLE

Hello

1. <tab/> Scope EXAMPLE

Hello

Example

2. 3. <tab/> Widgets 3.1. EXAMPLE 1

Hello

EXAMPLE

Hello

Example 1 Example (??)

<strong>Annex A</strong> <br/> (informative) A.1. EXAMPLE

Hello

A.2. EXAMPLE

Hello

EXAMPLE 1

Hello

OUTPUT end it "cross-references formulae" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

r = 1 % Preparatory r = 1 %
Scope r = 1 %

Widgets r = 1 % r = 1 %

r = 1 % r = 1 % r = 1 %
INPUT

Introduction, Formula (1) Preparatory, Formula ((??)) Clause 1, Formula (2) Clause 3.1, Formula (3) Clause 3.1, Formula (4) Formula (A.1) Formula ((??)) Formula (A.2)

1 r = 1 % Preparatory r = 1 %
1. <tab/> Scope 2 r = 1 %

Formula (2)

2. 3. <tab/> Widgets 3.1. 3 r = 1 % 4 r = 1 %

Formula (3) Formula (4)

<strong>Annex A</strong> <br/> (informative) A.1. A.1 r = 1 % A.2. r = 1 % A.2 r = 1 %
OUTPUT end it "cross-references requirements" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

r = 1 % Preparatory r = 1 %
Scope r = 1 %

Widgets r = 1 % r = 1 %

r = 1 % r = 1 % r = 1 %
INPUT

Introduction, Requirement 1 Preparatory, Requirement (??) Clause 1, Requirement 2 Clause 3.1, Requirement 3 Clause 3.1, Requirement 4 Requirement A.1 Requirement (??) Requirement A.2

Requirement 1 r = 1 % Preparatory Requirement r = 1 %
1. <tab/> Scope Requirement 2 r = 1 %

Requirement 2

2. 3. <tab/> Widgets 3.1. Requirement 3 r = 1 % Requirement 4 r = 1 %

Requirement 3 Requirement 4

<strong>Annex A</strong> <br/> (informative) A.1. Requirement A.1 r = 1 % A.2. Requirement r = 1 % Requirement A.2 r = 1 %
OUTPUT end it "cross-references recommendations" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

r = 1 % Preparatory r = 1 %
Scope r = 1 %

Widgets r = 1 % r = 1 %

r = 1 % r = 1 % r = 1 %
INPUT

Introduction, Recommendation 1 Preparatory, Recommendation (??) Clause 1, Recommendation 2 Clause 3.1, Recommendation 3 Clause 3.1, Recommendation 4 Recommendation A.1 Recommendation (??) Recommendation A.2

Recommendation 1 r = 1 % Preparatory Recommendation r = 1 %
1. <tab/> Scope Recommendation 2 r = 1 %

Recommendation 2

2. 3. <tab/> Widgets 3.1. Recommendation 3 r = 1 % Recommendation 4 r = 1 %

Recommendation 3 Recommendation 4

<strong>Annex A</strong> <br/> (informative) A.1. Recommendation A.1 r = 1 % A.2. Recommendation r = 1 % Recommendation A.2 r = 1 %
OUTPUT end it "cross-references permissions" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

r = 1 % Preparatory r = 1 %
Scope r = 1 %

Widgets r = 1 % r = 1 %

r = 1 % r = 1 % r = 1 %
INPUT

Introduction, Permission 1 Preparatory, Permission (??) Clause 1, Permission 2 Clause 3.1, Permission 3 Clause 3.1, Permission 4 Permission A.1 Permission (??) Permission A.2

Permission 1 r = 1 % Preparatory Permission r = 1 %
1. <tab/> Scope Permission 2 r = 1 %

Permission 2

2. 3. <tab/> Widgets 3.1. Permission 3 r = 1 % Permission 4 r = 1 %

Permission 3 Permission 4

<strong>Annex A</strong> <br/> (informative) A.1. Permission A.1 r = 1 % A.2. Permission r = 1 % Permission A.2 r = 1 %
OUTPUT end it "labels and cross-references nested requirements" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Preparatory Preparatory
INPUT

Clause 1, Permission 1 Clause 1, Permission 1-1 Clause 1, Permission 1-1-1 Clause 1, Requirement 1-1 Clause 1, Recommendation 1-1 Permission A.1 Permission A.1-1 Permission A.1-1-1 Requirement A.1-1 Recommendation A.1-1

1. <tab/> Preparatory Permission 1 Permission 1-1 Permission 1-1-1 Requirement 1-1 Recommendation 1-1 <strong>Annex A</strong> <br/> (informative) <br/> <br/> <strong>Preparatory</strong> Permission A.1 Permission A.1-1 Permission A.1-1-1 Requirement A.1-1 Recommendation A.1-1
OUTPUT end it "cross-references tables" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Preparatory Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Scope Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11

Widgets Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11

Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
INPUT

Table 1 Table (??) Table 2 Table 3 Table 4 Table A.1 Table (??) Table A.2

Table 1 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Preparatory Table  — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
1. <tab/> Scope Table 2 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11

Table 2

2. 3. <tab/> Widgets 3.1. Table 3 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Table 4 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11

Table 3 Table 4

<strong>Annex A</strong> <br/> (informative) A.1. Table A.1 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
A.2. Table  — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
Table A.2 — Repeatability and reproducibility of husked rice yield
Number of laboratories retained after eliminating outliers 13 11
OUTPUT end it "cross-references term notes" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Scope waxy rice

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

nonwaxy rice

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

INPUT

Clause 2.1, Note 1 Clause 2.2, Note 1 Clause 2.2, Note 2

1. <tab/> Scope 2. 2.1. waxy rice Note 1 to entry

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

2.2. nonwaxy rice Note 1 to entry

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

Note 2 to entry

The starch of waxy rice consists almost entirely of amylopectin. The kernels have a tendency to stick together after cooking.

OUTPUT end it "cross-references sections" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT") Foreword

This is a preamble

Introduction Introduction Subsection Text
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 Foreword

This is a preamble Introduction Subsection Introduction, 2 Clause 1 Clause 3 Clause 3.1 Clause 3.1.1 Clause 3.2 Clause 4 Clause 5 Clause 5.1 Clause 5.2 Annex A Annex A.1 Annex A.1.1 Annex B Annex B Annex B.1 Clause 2 Bibliography

Introduction Introduction Subsection Text
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 <strong>Annex B</strong> <br/> (informative) B. B.1. 2. <tab/> Normative References Bibliography Bibliography Subsection
OUTPUT end it "cross-references lists" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

  1. A

Preparatory
  1. A

Scope
  1. A

Widgets

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

INPUT

Introduction, List Preparatory, List Clause 1, List Clause 3.1, List 1 Clause 3.1, List 2 Annex A.1, List Annex A.2, List 1 Annex A.2, List 2

  1. A

Preparatory
  1. A

1. <tab/> Scope
  1. A

2. 3. <tab/> Widgets 3.1.

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

<strong>Annex A</strong> <br/> (informative) A.1.

    These results are based on a study carried out on three different types of kernel.

A.2.

    These results are based on a study carried out on three different types of kernel.

    These results are based on a study carried out on three different types of kernel.

OUTPUT end it "cross-references list items" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

  1. A

Preparatory
  1. A

Scope
  1. A

Widgets
  1. A

  1. A

  1. A

  1. A

  1. A

INPUT

Introduction, a) Preparatory, 1) Clause 1, i) Clause 3.1, List 1 a) Clause 3.1, List 2 I) Annex A.1, A) Annex A.2, List 1 iv) Annex A.2, List 2 a)

  1. A

Preparatory
  1. A

1. <tab/> Scope
  1. A

2. 3. <tab/> Widgets 3.1.
  1. A

  1. A

<strong>Annex A</strong> <br/> (informative) A.1.
  1. A

A.2.
  1. A

  1. A

OUTPUT end it "cross-references nested list items" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Scope
  1. A

    1. A

      1. A

        1. A

          1. A

            1. A

INPUT

Clause 1, a) Clause 1, a.1) Clause 1, a.1.i) Clause 1, a.1.i.A) Clause 1, a.1.i.A.I) Clause 1, a.1.i.A.I.a)

1. <tab/> Scope
  1. A

    1. A

      1. A

        1. A

          1. A

            1. A

OUTPUT end it "cross-references bookmarks" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Preparatory

Scope

Widgets

INPUT

Introduction Preparatory Clause 1 Note 2 Clause 3.1 Annex A.1 Figure A.1 Annex A.2

Preparatory

1. <tab/> Scope

2. 3. <tab/> Widgets 3.1. NOTE 1 NOTE 2

<strong>Annex A</strong> <br/> (informative) A.1.

A.2.
Figure A.1

OUTPUT end it "realises subsequences" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
INPUT

Figure 1 Figure 2a Figure 2b Figure 3a Figure 3b Figure 3c Figure 4 Figure 5

Figure 1 — Split-it-right sample divider
Figure 2a — Split-it-right sample divider
Figure 2b — Split-it-right sample divider
Figure 3a — Split-it-right sample divider
Figure 3b — Split-it-right sample divider
Figure 3c — Split-it-right sample divider
Figure 4 — Split-it-right sample divider
Figure 5 — Split-it-right sample divider
OUTPUT end it "realises numbering overrides" do expect(xmlpp(IsoDoc::PresentationXMLConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Split-it-right sample divider
Scope

Text

Terms and definitions

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

Term1
Abbreviated terms Clause 4 Introduction Clause A Clause B Clause C Clause D Clause E Clause F Clause G Clause H Clause I Terms and Definitions
First Annex Annex Annex A.1 Another Annex Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
INPUT

Figure 1 Figure A Figure B Figure 7 Figure 8 Figure 9a Figure 9c Figure 9d Figure 20f Figure 20g Figure A.1 Figure A.2 Figure 100

Clause 1bis Clause 2bis Clause 3bis Clause 3bis.4bis Clause 12bis Clause 13bis Clause 13bis.14bis Clause 13bis.14bit Clause 13bis.14biu Clause 13bis.0 Clause 13bis.1 Clause 13bis.2 Clause 13bis.a Clause 13bis.b Clause 13bis.B Clause 13bis.C Clause 16bis Annex A Annex 17bis Annex 17bis.18bis Annex 17bit Bibliography Bibliography Subsection

Figure 1 — Split-it-right sample divider
Figure A — Split-it-right sample divider
Figure B — Split-it-right sample divider
Figure 7 — Split-it-right sample divider
Figure 8 — Split-it-right sample divider
Figure 9a — Split-it-right sample divider
Figure 9c — Split-it-right sample divider
Figure 9d — Split-it-right sample divider
Figure 20f — Split-it-right sample divider
Figure 20g — Split-it-right sample divider
Figure A.1 — Split-it-right sample divider
Figure A.2 — Split-it-right sample divider
Figure 100 — Split-it-right sample divider
1bis. <tab/> Scope

Text

3bis. <tab/> Terms and definitions

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

3bis.4bis. Term1
12bis. <tab/> Abbreviated terms 13bis. <tab/> Clause 4 13bis.14bis. <tab/> Introduction 13bis.14bit. <tab/> Clause A 13bis.14biu. <tab/> Clause B 13bis.0. <tab/> Clause C 13bis.1. <tab/> Clause D 13bis.2. <tab/> Clause E 13bis.a. <tab/> Clause F 13bis.b. <tab/> Clause G 13bis.B. <tab/> Clause H 13bis.C. <tab/> Clause I 16bis. <tab/> Terms and Definitions
<strong>Annex A</strong> <br/> (normative) <br/> <br/> <strong>First Annex</strong> <strong>Annex 17bis</strong> <br/> (normative) <br/> <br/> <strong>Annex</strong> 17bis.18bis. <tab/> Annex A.1 <strong>Annex 17bit</strong> <br/> (normative) <br/> <br/> <strong>Another Annex</strong> 2bis. <tab/> Normative references

There are no normative references in this document.

Bibliography Bibliography Subsection
OUTPUT end it "realises roman counter for xrefs" do a = IsoDoc::XrefGen::Counter.new(0, numerals: :roman) a.increment({}) expect(a.print).to eq "I" a.increment({}) expect(a.print).to eq "II" a.increment({}) expect(a.print).to eq "III" a.increment({}) expect(a.print).to eq "IV" a.increment({}) expect(a.print).to eq "V" end end