require "spec_helper" RSpec.describe Metanorma::Iec do before(:all) do @blank_hdr = blank_hdr_gen end it "moves note from TC/SC officers to metadata" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == {blank} [NOTE] .Note from TC/SC Officers ==== This FDIS is the result of the discussion between the IEC SC21A experts WG 3 during the meeting held in Chicago (USA) on April 9th This document is also of interest for ISO/ TC114/ WG1 Requirements for Watch batteries ==== INPUT output = <<~OUTPUT International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 60 60 #{Time.new.year} International Electrotechnical Commission IEC article International standard

This FDIS is the result of the discussion between the IEC SC21A experts WG 3 during the meeting held in Chicago (USA) on April 9th

This document is also of interest for ISO/ TC114/ WG1 Requirements for Watch batteries

#{boilerplate(Nokogiri::XML(BLANK_HDR + '
'))} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "removes empty text elements" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == {blank} INPUT output = <<~OUTPUT #{@blank_hdr} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "keeps any initial boilerplate from terms and definitions" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions I am boilerplate * So am I === Time This paragraph is extraneous INPUT output = <<~OUTPUT #{@blank_hdr} Terms and definitions

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

#{TERMS_BOILERPLATE}

I am boilerplate

Time

This paragraph is extraneous

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "strips type from xrefs" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} <> [bibliography] == Clause * [[[iso216,ISO 216]]], _Reference_ INPUT output = <<~OUTPUT #{@blank_hdr} FOREWORD

Bibliography Reference ISO 216 216 International Organization for Standardization ISO OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "removes extraneous material from Normative References" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [bibliography] == Normative References This is extraneous information * [[[iso216,ISO 216]]], _Reference_ INPUT output = <<~OUTPUT #{@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 expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "inserts IDs into paragraphs" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} Paragraph INPUT output = <<~OUTPUT #{@blank_hdr}

Paragraph

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "inserts IDs into notes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [example] ==== NOTE: This note has no ID ==== INPUT output = <<~OUTPUT #{@blank_hdr}

This note has no ID

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "moves footnotes inside figures" do input = <<~INPUT #{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 output = <<~OUTPUT #{@blank_hdr}

This is a footnote to a figure

This is another footnote to a figure

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "defaults section obligations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Clause Text [appendix] == Clause Text INPUT output = <<~OUTPUT #{@blank_hdr} Clause

Text

Clause

Text

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "extends clause levels past 5" do input = <<~INPUT #{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 output = <<~OUTPUT #{@blank_hdr} Clause1 Clause2 Clause3 Clause4 Clause 5 Clause 6 Clause 7A Clause 7B Clause 6B Clause 5B OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end end