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

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")

INPUT


Foreword

a#b

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

INPUT end it "cross-references notes" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

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.  Scope

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

Note

2.  Terms and definitions

3.  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


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::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

Figure 1 — Split-it-right sample divider

Preparatory

Split-it-right sample divider

1.  Scope

Figure 2 — Split-it-right sample divider

Figure 2

2.  Terms and definitions

3.  Widgets

3.1. 

Figure 3 — Split-it-right sample divider

pseudocode

Figure 4

  
  A B C
 

Figure 5 — Source! Code!

EXAMPLE

    
  A B C
 

Figure 6 — Split-it-right sample divider

Figure 3 Figure 6


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

  
  A B C
 

Figure A.3 — Source! Code!

OUTPUT end it "cross-references subfigures" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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

1.  Scope

2.  Terms and definitions

3.  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


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::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Hello

Preparatory

Hello

Scope

Hello

Widgets

Hello

Hello

Hello

Hello

Hello

INPUT #{HTML_HDR}

Foreword

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


Introduction

EXAMPLE

Hello

Preparatory

EXAMPLE

Hello

1.  Scope

EXAMPLE

Hello

Example

2.  Terms and definitions

3.  Widgets

3.1. 

EXAMPLE 1

Hello

EXAMPLE

Hello

Example 1 Example (??)


A.1. 

EXAMPLE

Hello

A.2. 

EXAMPLE

Hello

EXAMPLE 1

Hello

OUTPUT end it "cross-references formulae" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

(#(r = 1 %)#)  (1)

Preparatory

(#(r = 1 %)#)

1.  Scope

(#(r = 1 %)#)  (2)

Formula (2)

2.  Terms and definitions

3.  Widgets

3.1. 

(#(r = 1 %)#)  (3)

(#(r = 1 %)#)  (4)

Formula (3) Formula (4)


A.1. 

(#(r = 1 %)#)  (A.1)

A.2. 

(#(r = 1 %)#)

(#(r = 1 %)#)  (A.2)

OUTPUT end it "cross-references requirements" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

Requirement 1:

(#(r = 1 %)#)

Preparatory

Requirement:

(#(r = 1 %)#)

1.  Scope

Requirement 2:

(#(r = 1 %)#)

Requirement 2

2.  Terms and definitions

3.  Widgets

3.1. 

Requirement 3:

(#(r = 1 %)#)

Requirement 4:

(#(r = 1 %)#)

Requirement 3 Requirement 4


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::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

Recommendation 1:

(#(r = 1 %)#)

Preparatory

Recommendation:

(#(r = 1 %)#)

1.  Scope

Recommendation 2:

(#(r = 1 %)#)

Recommendation 2

2.  Terms and definitions

3.  Widgets

3.1. 

Recommendation 3:

(#(r = 1 %)#)

Recommendation 4:

(#(r = 1 %)#)

Recommendation 3 Recommendation 4


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::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

Permission 1:

(#(r = 1 %)#)

Preparatory

Permission:

(#(r = 1 %)#)

1.  Scope

Permission 2:

(#(r = 1 %)#)

Permission 2

2.  Terms and definitions

3.  Widgets

3.1. 

Permission 3:

(#(r = 1 %)#)

Permission 4:

(#(r = 1 %)#)

Permission 3 Permission 4


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::HtmlConvert.new({}).convert("test", <<~"INPUT", true))).to be_equivalent_to xmlpp(<<~"OUTPUT")

Preparatory Preparatory
INPUT #{HTML_HDR}

Foreword

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 Annex A, Permission A.1 Annex A, Permission A.1-1 Annex A, Permission A.1-1-1 Annex A, Requirement A.1-1 Annex A, Recommendation A.1-1

1.  Preparatory

Permission 1:

Permission 1-1:

Permission 1-1-1:

Requirement 1-1:

Recommendation 1-1:


Annex A
(informative)

Preparatory

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::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

Table 1 — 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 outliers1311

1.  Scope

Table 2 — Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers 13 11

Table 2

2.  Terms and definitions

3.  Widgets

3.1. 

Table 3 — Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers1311

Table 4 — Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers1311

Table 3 Table 4


A.1. 

Table A.1 — Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers1311

A.2. 

Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers1311

Table A.2 — Repeatability and reproducibility of husked rice yield

Number of laboratories retained after eliminating outliers1311
OUTPUT end it "cross-references term notes" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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

1.  Scope

2.  Terms and definitions

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::HtmlConvert.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 #{HTML_HDR}

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 Clause 2 Bibliography


Introduction

Introduction Subsection

Text

1.  Scope

Text

2.  Normative references

3.  Terms, definitions, symbols and abbreviated terms

3.1.  Normal Terms

3.1.1.

Term2

3.2.  Symbols and abbreviated terms

Symbol

Definition

4.  Symbols and abbreviated terms

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


Bibliography

Bibliography Subsection

OUTPUT end it "cross-references lists" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

  1. A

Preparatory

  1. A

1.  Scope

  1. A

2.  Terms and definitions

3.  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.


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::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

  1. A

Preparatory

  1. A

1.  Scope

  1. A

2.  Terms and definitions

3.  Widgets

3.1. 

  1. A

  1. A


A.1. 

  1. A

A.2. 

  1. A

  1. A

OUTPUT end it "cross-references nested list items" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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.  Scope

  1. A

    1. A

      1. A

        1. A

          1. A

            1. A

OUTPUT end it "realises subsequences" do expect(xmlpp(IsoDoc::HtmlConvert.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 #{HTML_HDR}

Foreword

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


Introduction

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 end