require "spec_helper" require "fileutils" OPTIONS = [backend: :iec, header_footer: true].freeze RSpec.describe Asciidoctor::Iec do before(:all) do @blank_hdr = blank_hdr_gen end it "has a version number" do expect(Metanorma::Iec::VERSION).not_to be nil end it "processes a blank document" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} INPUT output = <<~OUTPUT #{@blank_hdr} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "converts a blank document" do FileUtils.rm_f "test.doc" FileUtils.rm_f "test.html" FileUtils.rm_f "test.pdf" input = <<~INPUT = Document title Author :docfile: test.adoc :novalid: :no-isobib: INPUT output = <<~OUTPUT #{@blank_hdr} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) expect(File.exist?("test.pdf")).to be true expect(File.exist?("test.html")).to be true expect(File.exist?("test.doc")).to be true expect(File.exist?("htmlstyle.css")).to be false end it "processes default metadata" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1 :edition: 2 :revdate: 2000-01-01 :draft: 0.3.4 :technical-committee: TC :technical-committee-number: 1 :technical-committee-type: A :subcommittee: SC :subcommittee-number: 2 :subcommittee-type: B :workgroup: WG :workgroup-number: 3 :workgroup-type: C :technical-committee_2: TC1 :technical-committee-number_2: 11 :technical-committee-type_2: A1 :subcommittee_2: SC1 :subcommittee-number_2: 21 :subcommittee-type_2: B1 :workgroup_2: WG1 :workgroup-number_2: 31 :workgroup-type_2: C1 :secretariat: SECRETARIAT :docstage: 10 :docsubstage: 20 :iteration: 3 :language: en :title-intro-en: Introduction :title-main-en: Main Title -- Title :title-part-en: Title Part :title-intro-fr: Introduction Française :title-main-fr: Titre Principal :title-part-fr: Part du Titre :library-ics: 1,2,3 :accessibility-color-inside: true :price-code: XC :cen-processing: true :secretary: Fred Nerk :interest-to-committees: TC 6121, SC 12 :obsoletes: ABC; DEF INPUT output = <<~OUTPUT Introduction — Main Title — Title — Title Part Introduction Main Title — Title Title Part Introduction Française — Titre Principal — Part du Titre Introduction Française Titre Principal Part du Titre IEC/3NWIP 1000-1 ED 2 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC 2 2000-01-01 0.3.4 en 10 20 3 #{Date.today.year} International Electrotechnical Commission IEC -- ABC -- DEF article false TC TC1 SC SC1 WG WG1 SECRETARIAT 1 2 3 IEC 1000 New work item proposal true XC true Fred Nerk TC 6121, SC 12

Copyright © #{Date.today.year} International Electrotechnical Commission, IEC. All rights reserved. It is permitted to download this electronic file, to make a copy and to print out the content for the sole purpose of preparing National Committee positions. You may not copy or “mirror” the file or printed version of the document, or any part of it, for any other purpose without permission in writing from IEC.

  1. The International Electrotechnical Commission (IEC) is a worldwide organization for standardization comprising all national electrotechnical committees (IEC National Committees). The object of IEC is to promote international co-operation on all questions concerning standardization in the electrical and electronic fields. To this end and in addition to other activities, IEC publishes International Standards, Technical Specifications, Technical Reports, Publicly Available Specifications (PAS) and Guides (hereafter referred to as “IEC Publication(s)”). Their preparation is entrusted to technical committees; any IEC National Committee interested in the subject dealt with may participate in this preparatory work. International, governmental and non-governmental organizations liaising with the IEC also participate in this preparation. IEC collaborates closely with the International Organization for Standardization (ISO) in accordance with conditions determined by agreement between the two organizations.

  2. The formal decisions or agreements of IEC on technical matters express, as nearly as possible, an international consensus of opinion on the relevant subjects since each technical committee has representation from all interested IEC National Committees.

  3. IEC Publications have the form of recommendations for international use and are accepted by IEC National Committees in that sense. While all reasonable efforts are made to ensure that the technical content of IEC Publications is accurate, IEC cannot be held responsible for the way in which they are used or for any misinterpretation by any end user.

  4. In order to promote international uniformity, IEC National Committees undertake to apply IEC Publications transparently to the maximum extent possible in their national and regional publications. Any divergence between any IEC Publication and the corresponding national or regional publication shall be clearly indicated in the latter.

  5. IEC itself does not provide any attestation of conformity. Independent certification bodies provide conformity assessment services and, in some areas, access to IEC marks of conformity. IEC is not responsible for any services carried out by independent certification bodies.

  6. All users should ensure that they have the latest edition of this publication.

  7. No liability shall attach to IEC or its directors, employees, servants or agents including individual experts and members of its technical committees and IEC National Committees for any personal injury, property damage or other damage of any nature whatsoever, whether direct or indirect, or for costs (including legal fees) and expenses arising out of the publication, use of, or reliance upon, this IEC Publication or any other IEC Publications.

  8. Attention is drawn to the Normative references cited in this publication. Use of the referenced publications is indispensable for the correct application of this publication.

  9. Attention is drawn to the possibility that some of the elements of this IEC Publication may be the subject of patent rights. IEC shall not be held responsible for identifying any or all such patent rights.

This document is still under study and subject to change. It should not be used for reference purposes. until published as such.

Recipients of this document are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation.

Attention IEC-CENELEC parallel voting

The attention of IEC National Committees, members of CENELEC, is drawn to the fact that this (NWIP) is submitted for parallel voting.

The CENELEC members are invited to vote through the CENELEC voting system.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes complex metadata" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: el :script: Grek :publisher: IEC;IETF;ISO :copyright-year: 2001 :docstage: A2CD :doctype: technical-specification :function: emc :horizontal: true INPUT output = <<~OUTPUT ISO/IEC/IETF/2CDTS 1000-1-1 ED 1 2000 1000 International Electrotechnical Commission IEC IETF International Organization for Standardization ISO International Electrotechnical Commission IEC IETF International Organization for Standardization ISO el 30 99 2 2001 International Electrotechnical Commission IEC 2001 IETF 2001 International Organization for Standardization ISO technical-specification true emc ISO/IEC/IETF 1000 Committee draft

Copyright © 2001 International Electrotechnical Commission, IEC. All rights reserved. It is permitted to download this electronic file, to make a copy and to print out the content for the sole purpose of preparing National Committee positions. You may not copy or “mirror” the file or printed version of the document, or any part of it, for any other purpose without permission in writing from IEC.

  1. The International Electrotechnical Commission (IEC) is a worldwide organization for standardization comprising all national electrotechnical committees (IEC National Committees). The object of IEC is to promote international co-operation on all questions concerning standardization in the electrical and electronic fields. To this end and in addition to other activities, IEC publishes International Standards, Technical Specifications, Technical Reports, Publicly Available Specifications (PAS) and Guides (hereafter referred to as “IEC Publication(s)”). Their preparation is entrusted to technical committees; any IEC National Committee interested in the subject dealt with may participate in this preparatory work. International, governmental and non-governmental organizations liaising with the IEC also participate in this preparation. IEC collaborates closely with the International Organization for Standardization (ISO) in accordance with conditions determined by agreement between the two organizations.

  2. The formal decisions or agreements of IEC on technical matters express, as nearly as possible, an international consensus of opinion on the relevant subjects since each technical committee has representation from all interested IEC National Committees.

  3. IEC Publications have the form of recommendations for international use and are accepted by IEC National Committees in that sense. While all reasonable efforts are made to ensure that the technical content of IEC Publications is accurate, IEC cannot be held responsible for the way in which they are used or for any misinterpretation by any end user.

  4. In order to promote international uniformity, IEC National Committees undertake to apply IEC Publications transparently to the maximum extent possible in their national and regional publications. Any divergence between any IEC Publication and the corresponding national or regional publication shall be clearly indicated in the latter.

  5. IEC itself does not provide any attestation of conformity. Independent certification bodies provide conformity assessment services and, in some areas, access to IEC marks of conformity. IEC is not responsible for any services carried out by independent certification bodies.

  6. All users should ensure that they have the latest edition of this publication.

  7. No liability shall attach to IEC or its directors, employees, servants or agents including individual experts and members of its technical committees and IEC National Committees for any personal injury, property damage or other damage of any nature whatsoever, whether direct or indirect, or for costs (including legal fees) and expenses arising out of the publication, use of, or reliance upon, this IEC Publication or any other IEC Publications.

  8. Attention is drawn to the Normative references cited in this publication. Use of the referenced publications is indispensable for the correct application of this publication.

  9. Attention is drawn to the possibility that some of the elements of this IEC Publication may be the subject of patent rights. IEC shall not be held responsible for identifying any or all such patent rights.

This document is still under study and subject to change. It should not be used for reference purposes. until published as such.

Recipients of this document are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation.

Attention IEC-CENELEC parallel voting

The attention of IEC National Committees, members of CENELEC, is drawn to the fact that this Committee Draft (CD) is submitted for parallel voting.

The CENELEC members are invited to vote through the CENELEC voting system.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes boilerplate in English" do doc = strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)) = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: en :script: Latn :publisher: IEC,IETF,ISO :copyright-year: 2001 INPUT expect(doc).to include "including individual experts" expect(doc).not_to include "y compris ses experts particuliers" end it "processes boilerplate in French" do doc = strip_guid(Asciidoctor.convert(<<~"INPUT", *OPTIONS)) = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :partnumber: 1-1 :tc-docnumber: 2000 :language: fr :script: Latn :publisher: IEC,IETF,ISO :copyright-year: 2001 INPUT expect(doc).not_to include "including individual experts" expect(doc).to include "y compris ses experts particuliers" end it "defaults substage" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 50 INPUT output = <<~OUTPUT IEC/FDIS 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 50 00 #{Date.today.year} International Electrotechnical Commission IEC article false IEC 1000 Final draft international standard

Copyright © #{Time.now.year} International Electrotechnical Commission, IEC. All rights reserved. It is permitted to download this electronic file, to make a copy and to print out the content for the sole purpose of preparing National Committee positions. You may not copy or “mirror” the file or printed version of the document, or any part of it, for any other purpose without permission in writing from IEC.

  1. The International Electrotechnical Commission (IEC) is a worldwide organization for standardization comprising all national electrotechnical committees (IEC National Committees). The object of IEC is to promote international co-operation on all questions concerning standardization in the electrical and electronic fields. To this end and in addition to other activities, IEC publishes International Standards, Technical Specifications, Technical Reports, Publicly Available Specifications (PAS) and Guides (hereafter referred to as “IEC Publication(s)”). Their preparation is entrusted to technical committees; any IEC National Committee interested in the subject dealt with may participate in this preparatory work. International, governmental and non-governmental organizations liaising with the IEC also participate in this preparation. IEC collaborates closely with the International Organization for Standardization (ISO) in accordance with conditions determined by agreement between the two organizations.

  2. The formal decisions or agreements of IEC on technical matters express, as nearly as possible, an international consensus of opinion on the relevant subjects since each technical committee has representation from all interested IEC National Committees.

  3. IEC Publications have the form of recommendations for international use and are accepted by IEC National Committees in that sense. While all reasonable efforts are made to ensure that the technical content of IEC Publications is accurate, IEC cannot be held responsible for the way in which they are used or for any misinterpretation by any end user.

  4. In order to promote international uniformity, IEC National Committees undertake to apply IEC Publications transparently to the maximum extent possible in their national and regional publications. Any divergence between any IEC Publication and the corresponding national or regional publication shall be clearly indicated in the latter.

  5. IEC itself does not provide any attestation of conformity. Independent certification bodies provide conformity assessment services and, in some areas, access to IEC marks of conformity. IEC is not responsible for any services carried out by independent certification bodies.

  6. All users should ensure that they have the latest edition of this publication.

  7. No liability shall attach to IEC or its directors, employees, servants or agents including individual experts and members of its technical committees and IEC National Committees for any personal injury, property damage or other damage of any nature whatsoever, whether direct or indirect, or for costs (including legal fees) and expenses arising out of the publication, use of, or reliance upon, this IEC Publication or any other IEC Publications.

  8. Attention is drawn to the Normative references cited in this publication. Use of the referenced publications is indispensable for the correct application of this publication.

  9. Attention is drawn to the possibility that some of the elements of this IEC Publication may be the subject of patent rights. IEC shall not be held responsible for identifying any or all such patent rights.

This document is a draft distributed for approval. It may not be referred to as an International Standard until published as such.

In addition to their evaluation as being acceptable for industrial, technological, commercial and user purposes, Final Draft International Standards may on occasion have to be considered in the light of their potential to become standards to which reference may be made in national regulations.

Recipients of this document are invited to submit, with their comments, notification of any relevant patent rights of which they are aware and to provide supporting documentation.

Attention IEC-CENELEC parallel voting

The attention of IEC National Committees, members of CENELEC, is drawn to the fact that this Final Draft International Standard (FDIS) is submitted for parallel voting.

The CENELEC members are invited to vote through the CENELEC voting system.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "defaults substage for stage 60" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 60 INPUT output = <<~OUTPUT IEC 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 60 60 #{Date.today.year} International Electrotechnical Commission IEC article false IEC 1000 International standard #{boilerplate(Nokogiri::XML(BLANK_HDR + ''))} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "populates metadata for PRF" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :no-isobib: :docnumber: 1000 :docstage: 60 :docsubstage: 00 INPUT output = <<~OUTPUT IEC 1000 ED 1 1000 International Electrotechnical Commission IEC International Electrotechnical Commission IEC en 60 00 #{Date.today.year} International Electrotechnical Commission IEC article false IEC 1000 International standard #{boilerplate(Nokogiri::XML(BLANK_HDR + ''))} OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "reads scripts into blank HTML document" do FileUtils.rm_f "test.html" Asciidoctor.convert(<<~"INPUT", *OPTIONS) = Document title Author :docfile: test.adoc :novalid: :no-isobib: :no-pdf: INPUT html = File.read("test.html", encoding: "utf-8") expect(html).to match(%r{