require "spec_helper" require "relaton_iec" require "fileutils" RSpec.describe Metanorma::Standoc do it "processes term and designation metadata and term sources" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === First Designation [%metadata] language:: fr script:: Latn type:: prefix isInternational:: true abbreviation-type:: acronym pronunciation:: fəɹst domain:: Hydraulics subject:: pipes field-of-application:: Field usage-info:: This is usage. [.source] <> alt:[Third Designation] [%metadata] language:: he script:: Hebr type:: suffix domain:: Hydraulics1 subject: pipes1 usage-info:: This is usage 1. absent:: true deprecated:[Fourth Designation] [%metadata] language:: jp script:: Japn type:: full field-of-application:: Field grammar:: gender::: masculine, feminine number::: singular, plural isPreposition::: false isNoun::: true grammar-value::: irregular declension geographic-area:: AUS related:see[<>,Fifth Designation] [%metadata] type:: abbreviation grammar:: gender::: neuter isVerb::: true geographic-area:: GRC [.source] <> Definition [.source] <> [[second]] === Second Term [%metadata] usage-info:: + -- Usage Info 1. Usage Info 2. -- INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

First Designation acronym fəɹst Field This is usage. 1 Third Designation This is usage 1. Fourth Designation masculine feminine singular plural false true irregular declension Field Fifth Designation neuter 2 Hydraulics pipes

Definition

3
Second Term

Usage Info 1.

Usage Info 2.

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "permits multiple preferred terms and admitted terms, "\ "and treats them as synonyms in concepts" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === First Designation preferred:[Second Designation] alt:[Third Designation] alt:[Fourth Designation] deprecated:[Fourth Designation] deprecated:[Fifth Designation] related:see[Sixth Designation] related:contrast[Seventh Designation] Definition == Clause {{First Designation}} {{Second Designation}} {{Third Designation}} INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

First Designation Second Designation Third Designation Fourth Designation Fourth Designation Fifth Designation term Sixth Designation not resolved via ID Sixth-Designation term Seventh Designation not resolved via ID Seventh-Designation

Definition

Clause

First Designation First Designation

First Designation Second Designation

First Designation Third Designation

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "respects case in tagging of concepts" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === First Designation Definition === First designation Definition == Clause {{First Designation}} {{First designation}} INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

First Designation

Definition

First designation

Definition

Clause

First Designation First Designation

First designation First designation

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes letter-symbol designations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === First Designation [%metadata] letter-symbol:: true preferred:[Second Designation] [%metadata] letter-symbol:: false alt:[Third Designation] [%metadata] letter-symbol:: true deprecated:[stem:[t_90]] related:see[<>,Fifth Designation] [%metadata] letter-symbol:: true Definition INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

First Designation Second Designation Third Designation t 90 Fifth Designation

Definition

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes empty designations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions [[second]] === {blank} [%metadata] isInternational:: true preferred:[] alt:[] deprecated:[] related:see[<>,] Definition INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Definition

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes graphical-symbol designations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions [[second]] === {blank} .Caption .... FIGURATIVE .... [%metadata] isInternational:: true preferred:[] .Caption .... FIGURATIVE .... alt:[] .Caption .... FIGURATIVE .... deprecated:[] .Caption .... FIGURATIVE .... related:see[<>,] .Caption .... FIGURATIVE .... Definition INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

<LITERAL> FIGURATIVE
<LITERAL> FIGURATIVE
<LITERAL> FIGURATIVE
<LITERAL> FIGURATIVE
Caption
<LITERAL> FIGURATIVE

Definition

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "sorts designations" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions [[des1]] === First Designation [%metadata] language:: fr script:: Latn type:: prefix isInternational:: true abbreviation-type:: acronym pronunciation:: fəɹst domain:: Hydraulics subject:: pipes usage-info:: This is usage. related:see[<>,Fifth Designation] [%metadata] grammar:: gender::: neuter isVerb::: true deprecated:[Fourth Designation] [%metadata] language:: jp script:: Japn type:: full grammar:: gender::: masculine, feminine isPreposition::: false isNoun::: true grammar-value::: irregular declension alt:[Third Designation] [%metadata] language:: he script:: Hebr type:: suffix domain:: Hydraulics1 subject: pipes1 usage-info:: This is usage 1. preferred:[Second Designation] [%metadata] type:: abbreviation Definition INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

First Designation acronym fəɹst This is usage. Second Designation Third Designation This is usage 1. Fourth Designation masculine feminine false true irregular declension Fifth Designationneuter Hydraulics pipes

Definition

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes stem-only terms as admitted" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === stem:[t_90] stem:[t_91] Time INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

t 90 t 91

Time

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "differentiates stem-only and mixed terms" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === stem:[t_90] Time === stem:[t_90]-sensitivity Sensitivity === sensitivity to stem:[t_90] Sensitivity #2 INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

t 90

Time

t 90 -sensitivity

Sensitivity

sensitivity to#{' '} t 90

Sensitivity #2

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "moves term domains out of the term definition paragraph" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === Tempus domain:[relativity] Time === Tempus1 Time2 domain:[relativity2] INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Tempus relativity

Time

Tempus1 relativity2

Time2

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "permits multiple blocks in term definition paragraph" do input = <<~INPUT = Document title Author :docfile: test.adoc :nodoc: :novalid: :stem: == Terms and Definitions === stem:[t_90] [stem] ++++ t_A ++++ This paragraph is extraneous * This is a list [] . This too is a list [] This is:: another list This is a concluding paragraph INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

t 90 t A

This paragraph is extraneous

  • This is a list

  1. This too is a list

This is

another list

This is a concluding paragraph

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "rearranges term note, term example, term source" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and definitions === Term Definition [.source] <> NOTE: Note [example] Example 1 NOTE: Note 2 [example] Example 2 INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Term

Definition

Note

Note 2

Example 1

Example 2

1
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "supports non-verbal definitions" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and definitions === Term [.definition] -- Definition [.source] <> -- [.definition] -- |=== | A | B | C | D |=== -- [.source] <> === Term 2 [.definition] -- .... Literal .... [stem] ++++ x = y ++++ [.source] <> -- INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Term

Definition

1
A B
C D
2
Term 2
Literal
x = y 3
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "differentiates stem expressions before, after, and within verbal definitions" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and definitions === Term stem:[lambda] [.definition] -- Definition stem:[mu] -- [.definition] -- stem:[nu] -- INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Term λ

Definition

μ

ν

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "differentiates formuals before, after, and within verbal definitions" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} == Terms and definitions === Term [stem] ++++ lambda ++++ [.definition] -- Definition [stem] ++++ mu ++++ -- [.definition] -- [stem] ++++ nu ++++ -- INPUT output = <<~OUTPUT #{BLANK_HDR} Terms and definitions

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

Term λ

Definition

μ
ν
OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "automatically indexes term indexes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR.sub(/:nodoc:\n/, ":nodoc:\n:index-terms:\n")} == Terms and definitions === Term [stem] ++++ lambda ++++ admitted:[x] === Term2 preferred:[stem:[mu_0 // 2]] == Symbols and Abbreviated Terms x^2^:: Definition INPUT output = <<~OUTPUT Document title en published #{Time.now.year} standard Terms and definitions

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

Term Term x λ Term2 Term2 μ 0 / 2 μ 0 / 2
Symbols and abbreviated terms
x 2 x 2

Definition

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end end