require "spec_helper" RSpec.describe Metanorma::Standoc do it "processes the Metanorma::Standoc inline macros" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} preferred:[term0] alt:[term1] admitted:[term1a] deprecated:[term2] domain:[term3] inherit:[<>] autonumber:table[3] add:[a <>] del:[B] identifier:[a http://example.com] span:category[text] [bibliography] == Bibliography * [[[ref1,XYZ 123]]] _Title_ INPUT output = <<~OUTPUT #{BLANK_HDR} Foreword term0 term1 term1a term2 term3 3 a B a http://example.com text Bibliography Title XYZ 123 123 OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes the Metanorma::Standoc index macros" do input = <<~INPUT #{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 output = <<~OUTPUT #{BLANK_HDR}

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

Text

Text

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes the Metanorma::Standoc variant macros" do input = <<~INPUT #{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 output = <<~OUTPUT #{BLANK_HDR} <variant lang='en'>English</variant> <variant lang='fr' script='Latn'>Français</variant>

this English Français section is silly fou

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes the macro for editorial notes" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} EDITOR: Note1 [EDITOR] ==== Note2 ==== [EDITOR] Note3 INPUT output = <<~OUTPUT #{BLANK_HDR}

Note1

Note2

Note3

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes the TODO custom admonition" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} TODO: Note1 [TODO] ==== Note2 ==== [TODO] Note3 INPUT output = <<~OUTPUT #{BLANK_HDR}

Note1

Note2

Note3

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

  A
        B

  C

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

A
B

D
E

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

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

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

a b
c d

  • A

  • B

  • C

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

[ERROR]

a b
c d
  • A

  • B

  • C

OUTPUT expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS)))) .to be_equivalent_to xmlpp(output) end it "processes input form macros" do input = <<~INPUT #{ASCIIDOC_BLANK_HDR} [form,id=N0,name=N1,action="/action_page.php",class="checkboxes"] -- label:fname[First name:] + input:text[id=fname,name=fname] + label:lname[Last name:] + input:text[id=lname,name=lname] + label:pwd[Password:] + input:password[id=pwd,name=pwd] + input:radio[id=male,name=gender,value=male] label:male[Male] + input:radio[id=female,name=gender,value=female] label:female[Female] + input:radio[id=other,name=gender,value=other] label:other[Other] + input:checkbox[id=vehicle1,name=vehicle1,value=Bike,checked=true] label:vehicle1[I have a bike] + input:checkbox[id=vehicle2,name=vehicle2,value=Car] label:vehicle2[I have a car] + input:checkbox[id=vehicle3,name=vehicle3,value=Boat] label:vehicle3[I have a boat] + input:date[id=birthday,name=birthday] + label:myfile[Select a file:] input:file[id=myfile,name=myfile] + label:cars[Select a car:] + select:[id=cars,name=cars,value=fiat,size=4,disabled=true,multiple=true] option:[Volvo,value=volvo,disabled=true] option:[Saab,value=saab] option:[Fiat,value=fiat] option:[Audi,value=audi] textarea:[id=t1,name=message,rows=10,cols=30,value="The cat was playing in the garden."] input:button[value="Click Me!"] input:button[] input:submit[value="Submit"] -- INPUT output = <<~OUTPUT #{BLANK_HDR}