require "spec_helper" RSpec.describe Asciidoctor::Standoc do it "processes the Asciidoctor::Standoc inline macros" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} alt:[term1] deprecated:[term1] domain:[term1] inherit:[<>] autonumber:table[3] [bibliography] == Bibliography * [[[ref1,XYZ 123]]] _Title_ INPUT #{BLANK_HDR} Foreword term1 term1 term1 3 Bibliography Title XYZ 123 123 OUTPUT end it "processes the Asciidoctor::Standoc index macros" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} index:also[] index:see[A] index:also[B,C~x~] index:see[D,_E_,F] index:also[G,H,I,J] index:see[K,L,M,N,O] index-range:id2[P] index-range:id3[((_P_))] index-range:id3[(((Q, R, S)))] Text [[id2]] Text [[id3]] INPUT #{BLANK_HDR}

B C x D E F G H I J P P P P Q R S

Text

Text

OUTPUT end it "processes the Asciidoctor::Standoc variant macros" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} == lang:en[English] lang:fr-Latn[Français] this lang:en[English] lang:fr-Latn[Français] section is lang:en[silly] lang:fr[fou] INPUT #{BLANK_HDR} <variant lang='en'>English</variant> <variant lang='fr' script='Latn'>Français</variant>

this English Français section is silly fou

OUTPUT end it "processes the Asciidoctor::Standoc concept macros" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} {{clause1}} {{clause1,w\[o\]rd}} {{clause1,w\[o\]rd,term}} {{blah}} {{blah,word}} {{blah,word,term}} {{blah,clause=3.1}} {{blah,clause=3.1,word}} {{blah,clause=3.1,word,term}} {{blah,clause=3.1,figure=a}} {{blah,clause=3.1,figure=a,word}} {{blah,clause=3.1,figure=a,word,term}} {{IEV:135-13-13}} {{IEV:135-13-13,word}} {{IEV:135-13-13,word,term}} [[clause1]] == Clause Terms are defined here [bibliography] == Bibliography * [[[blah,blah]]] _Blah_ INPUT #{BLANK_HDR} Foreword

w[o]rd w[o]rd word word 3.1 3.1 word 3.1 word 3.1 a 3.1 a word 3.1 a word word word

Clause

Terms are defined here

Bibliography Blah blah OUTPUT end it "processes the TODO custom admonition" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} TODO: Note1 [TODO] ==== Note2 ==== [TODO] Note3 INPUT #{BLANK_HDR}

Note2

Note3

OUTPUT end it "generates pseudocode examples, with formatting and initial indentation" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [pseudocode,subsequence="A",number="3",keep-with-next=true,keep-lines-together=true] [%unnumbered] ==== *A* + [smallcap]#B# _C_ ==== INPUT #{BLANK_HDR}

  A
        B

  C

OUTPUT end it "supplies line breaks in pseudocode" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [pseudocode] ==== A B D E ==== INPUT #{BLANK_HDR}

A
B

D
E

OUTPUT end it "skips embedded blocks when supplying line breaks in pseudocode" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} [pseudocode] ==== [stem] ++++ bar X' = (1)/(v) sum_(i = 1)^(v) t_(i) ++++ ==== INPUT #{BLANK_HDR}
X ¯ = 1 v i = 1 v t i
OUTPUT end it "processes the Ruby markups" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} ruby:楽聖少女[がくせいしょうじょ] INPUT #{BLANK_HDR}

楽聖少女(がくせいしょうじょ)

OUTPUT end it "processes the footnoteblock macro" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} footnoteblock:[id1] [[id1]] [NOTE] -- |=== |a |b |c |d |=== * A * B * C -- INPUT #{BLANK_HDR}

a b
c d

OUTPUT end it "processes the footnoteblock macro with failed reference" do expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT") #{ASCIIDOC_BLANK_HDR} footnoteblock:[id1] [[id2]] [NOTE] -- |=== |a |b |c |d |=== * A * B * C -- INPUT #{BLANK_HDR}

[ERROR]

a b
c d
  • A

  • B

  • C

OUTPUT end describe 'term inline macros' do subject(:convert) do xmlpp( strip_guid( Asciidoctor.convert( input, backend: :standoc, header_footer: true))) end let(:input) do <<~XML #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === name2 == Main term:[name,name2] is a term XML end let(:output) do <<~XML #{BLANK_HDR} Terms and definitions

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

name2
Main

name ( ) is a term

XML end it 'converts macro into the correct xml' do expect(convert).to(be_equivalent_to(xmlpp(output))) end context 'default params' do let(:input) do <<~XML #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === name == Main term:[name] is a term XML end let(:output) do <<~XML #{BLANK_HDR} Terms and definitions

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

name
Main

name ( ) is a term

XML end it 'uses `name` as termref name' do expect(convert).to(be_equivalent_to(xmlpp(output))) end end context 'multiply exising ids in document' do let(:input) do <<~XML #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === name === name2 [[term-name]] == Main paragraph [[term-name2]] == Second term:[name] is a term term:[name2] is a term XML end let(:output) do <<~XML #{BLANK_HDR} Terms and definitions

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

name name2
Main

paragraph

Second

name ( ) is a term name2 ( ) is a term

XML end it 'generates unique ids which do not match existing ids' do expect(convert).to(be_equivalent_to(xmlpp(output))) end end context 'when missing actual ref' do let(:input) do <<~XML #{ASCIIDOC_BLANK_HDR} == Terms and Definitions === name identity [[name-check]] === name check paragraph term:[name check] is a term term:[name identity] is a term Moreover, term:[missing] is a term XML end let(:output) do <<~XML #{BLANK_HDR} Terms and definitions

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

name identity name check

paragraph

name check ( ) is a term

name identity ( ) is a term

Moreover, (term “missing” not resolved) is a term

XML end it 'generates unique ids which do not match existing ids' do expect(convert).to(be_equivalent_to(xmlpp(output))) end end end end