require "spec_helper" RSpec.describe IsoDoc do it "cross-references notes" do input = <<~INPUT

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 output = <<~OUTPUT

Clause 1, Note 3.1, Note 1 3.1, Note 2 A.1, Note A.2, Note 1 A.2, Note 2

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/><span class="obligation">(informative)</span> 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 expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "cross-references figures" do input = <<~INPUT

Scope
Split-it-right sample divider

Widgets
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 output = <<~OUTPUT

Figure 1 Figure 2 Figure 3 Figure A.1 Figure A.2 Figure A.3

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

Figure 1

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

Figure 2 Figure 3

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

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

Split-it-right sample divider
Split-it-right sample divider
INPUT output = <<~OUTPUT

Figure 1 Figure 1 a) Figure 1 b) Figure A.1 Figure A.1 a) Figure A.1 b)

1 <tab/> Scope 2 3 <tab/> Widgets 3.1
Figure 1
a)  Split-it-right sample divider
b)  Split-it-right sample divider

Figure 1 a) Figure 1 b)

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

Scope

Hello

Widgets

Hello

Hello

Hello

Hello

Hello

INPUT output = <<~OUTPUT

Clause 1, Example 3.1, Example 1 3.1, Example 2 A.1, Example A.2, Example 1 A.2, Example 2

1 <tab/> Scope EXAMPLE

Hello

Example

2 3 <tab/> Widgets 3.1 EXAMPLE 1

Hello

EXAMPLE 2

Hello

Example 1 Example 2

<strong>Annex A</strong> <br/><span class="obligation">(informative)</span> A.1 EXAMPLE

Hello

A.2 EXAMPLE 1

Hello

EXAMPLE 2

Hello

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

Scope r = 1 %

Widgets r = 1 % r = 1 %

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

is the repeatability limit.

INPUT output = <<~OUTPUT

Clause 1, Formula (1) 3.1, Formula (2) 3.1, Formula (3) A.1, Formula (A.1) A.2, Formula (A.2) A.2, Formula (A.3)

1 <tab/> Scope 1 r = 1 %

Formula (1)

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

Formula (2) Formula (3)

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

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 output = <<~OUTPUT

Table 1 Table 2 Table 3 Table A.1 Table A.2 Table A.3

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

Table 1

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

Table 2 Table 3

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

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 output = <<~OUTPUT

2.1, Note 1 2.2, Note 1 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 expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "cross-references sections" do input = <<~INPUT 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 An Appendix Appendix subclause Normative References Bibliography Bibliography Subsection
INPUT output = <<~OUTPUT Foreword

This is a preamble 0.1 0.2 Clause 1 Clause 3 3.1 3.1.1 3.2 Clause 4 Clause 5 5.1 5.2 Annex A A.1 A.1.1 Annex A, Appendix 1 Annex A, Appendix 1.1 Clause 2

0 <tab/> Introduction 0.1 <tab/> Introduction Subsection 0.2 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/> <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 Appendix 1.1 <tab/> Appendix subclause 2 <tab/> Normative References Bibliography Bibliography Subsection
OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "cross-references lists" do output = IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", <<~"INPUT", true)

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 expect(xmlpp(output)).to be_equivalent_to xmlpp(<<~"OUTPUT")

Clause 1, List 3.1, List 1 3.1, List 2 A.1, List A.2, List 1 A.2, List 2

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/><span class="obligation">(informative)</span> 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 input = <<~INPUT

Scope
  1. A

Widgets
  1. A

  1. A

  1. A

  1. A

  1. A

INPUT output = <<~OUTPUT

1 a) 3.1, List 1 a) 3.1, List 2 a) A.1 a) A.2, List 1 a) A.2, List 2 a)

1<tab/>Scope
  1. A

2 3<tab/>Widgets 3.1
  1. A

  1. A

<strong>Annex A</strong><br/><span class="obligation">(informative)</span> A.1
  1. A

A.2
  1. A

  1. A

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

Scope
  1. A

    1. A

      1. A

        1. A

          1. A

            1. A

INPUT output = <<~OUTPUT

1 a) 1 a) 1) 1 a) 1) i) 1 a) 1) i) A) 1 a) 1) i) A) I) 1 a) 1) i) A) I) a)

1<tab/>Scope
  1. A

    1. A

      1. A

        1. A

          1. A

            1. A

OUTPUT expect(xmlpp(IsoDoc::Iso::PresentationXMLConvert.new({}) .convert("test", input, true))).to be_equivalent_to xmlpp(output) end it "conflates cross-references to a split list" do input = <<~INPUT

Scope
  1. A

  2. A

  1. A

  2. A

  1. A

  2. A

INPUT output = <<~OUTPUT

1 a)

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

Scope
  1. A

  2. A

  1. A

  2. A

  1. A

  2. A

INPUT output = <<~OUTPUT

Clause 1, List 1 a)

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