require "spec_helper" RSpec.describe Asciidoctor::Iec do it "removes empty text elements" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == {blank} INPUT #{BLANK_HDR} OUTPUT end it "processes stem-only terms as admitted" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === stem:[t_90] stem:[t_91] Time INPUT #{BLANK_HDR} Terms and definitions

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

#{TERMS_BOILERPLATE} t90t91

Time

OUTPUT end it "permits multiple blocks in term definition paragraph" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") = Document title Author :docfile: test.adoc :nodoc: :novalid: :stem: :no-isobib: == Terms and Definitions === stem:[t_90] [stem] ++++ t_A ++++ This paragraph is extraneous INPUT #{BLANK_HDR} Terms and definitions

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

#{TERMS_BOILERPLATE} t90 tA

This paragraph is extraneous

OUTPUT end it "strips any initial boilerplate from terms and definitions" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == Terms and Definitions I am boilerplate * So am I === Time This paragraph is extraneous INPUT #{BLANK_HDR} Terms and definitions

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

#{TERMS_BOILERPLATE} Time

This paragraph is extraneous

OUTPUT end it "strips type from xrefs" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} <> [bibliography] == Clause * [[[iso216,ISO 216]]], _Reference_ INPUT #{BLANK_HDR} Foreword

Bibliography Reference ISO 216 216 International Organization for Standardization ISO OUTPUT end it "processes localities in term sources" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === Term1 [.source] <> INPUT #{BLANK_HDR} Terms and definitions

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

#{TERMS_BOILERPLATE} Term1 1
OUTPUT end it "removes extraneous material from Normative References" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [bibliography] == Normative References This is extraneous information * [[[iso216,ISO 216]]], _Reference_ INPUT #{BLANK_HDR} Normative References

The following documents are referred to in the text in such a way that some or all of their content constitutes requirements of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies.

Reference ISO 216 216 International Organization for Standardization ISO
OUTPUT end it "inserts IDs into paragraphs" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} Paragraph INPUT #{BLANK_HDR}

Paragraph

OUTPUT end it "inserts IDs into notes" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [example] ==== NOTE: This note has no ID ==== INPUT #{BLANK_HDR}

This note has no ID

OUTPUT end it "moves table key inside table" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} |=== |a |b |c |=== Key a:: b INPUT #{BLANK_HDR}
a

b

a b c
OUTPUT end it "moves formula key inside formula" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [stem] ++++ Formula ++++ where a:: b INPUT #{BLANK_HDR} Forμla
a

b

OUTPUT end it "moves footnotes inside figures" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} image::spec/examples/rice_images/rice_image1.png[] footnote:[This is a footnote to a figure] footnote:[This is another footnote to a figure] INPUT #{BLANK_HDR}

This is a footnote to a figure

This is another footnote to a figure

OUTPUT end it "moves figure key inside figure" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} image::spec/examples/rice_images/rice_image1.png[] Key a:: b INPUT #{BLANK_HDR}
a

b

OUTPUT end it "defaults section obligations" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == Clause Text [appendix] == Clause Text INPUT #{BLANK_HDR} Clause

Text

Clause

Text

OUTPUT end it "extends clause levels past 5" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iec, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == Clause1 === Clause2 ==== Clause3 ===== Clause4 ====== Clause 5 [level=6] ====== Clause 6 [level=7] ====== Clause 7A [level=7] ====== Clause 7B [level=6] ====== Clause 6B ====== Clause 5B INPUT #{BLANK_HDR} Clause1 Clause2 Clause3 Clause4 Clause 5 Clause 6 Clause 7A Clause 7B Clause 6B Clause 5B OUTPUT end end