require "spec_helper"
RSpec.describe Asciidoctor::Standoc do
it "handles spacing around markup" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
This is
a paragraph with <>
markup _for_
text, including **__nest__**ed markup.
INPUT
output = <<~OUTPUT
Document titleenpublished#{Date.today.year}article
This is
a paragraph with
markup for
text, including nested markup.
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes inline_quoted formatting" do
input = <<~INPUT
#{DUMBQUOTE_BLANK_HDR}
_Physical noise
sources_
*strong*
`monospace`
"double quote"
'single quote'
super^script^
sub~script~
sub~__scr__ipt~
stem:[FΑ]
#mark#
[alt]#alt#
[deprecated]#deprecated#
[domain]#domain#
[strike]#strike#
[underline]#underline#
[smallcap]#smallcap#
[keyword]#keyword#
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
Physical noise sourcesstrongmonospace
"double quote"
'single quote'
superscript
subscript
subscript
mark
altdeprecateddomainstrikeunderlinesmallcapkeyword
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "process mtext spaces" do
input = <<~INPUT
#{DUMBQUOTE_BLANK_HDR}
stem:[n < 1 " for all text "]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "properly handles inline substitution" do
input = <<~INPUT
#{DUMBQUOTE_BLANK_HDR}
stem:[n < 1] +
latexmath:[n < 1]
stem:[""^199 "Hg"^+]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "normalises inline stem, straight quotes" do
input = <<~INPUT
#{DUMBQUOTE_BLANK_HDR}
stem:[n < 1]
latexmath:[n < 1]
stem:[""^199 "Hg"^+]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "normalises inline stem, smart quotes" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
stem:[n < 1]
latexmath:[n < 1]
stem:[""^199 "Hg"^+]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "generates desired smart quotes for 'dd'" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
'99'.
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
‘99’.
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes breaks" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
Line break +
line break
'''
<<<
[%landscape]
<<<
[%portrait]
<<<
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
Line break
line break
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes links" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
mailto:fred@example.com
http://example.com[]
http://example.com[Link]
http://example.com[Link,title="tip"]
link:++https://asciidoctor.org/now_this__link_works.html++[]
http://example.com[Link,updatetype=true]
link:../example[updatetype=true]
link:../example[Link,updatetype=true]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
mailto:fred@example.com
Link
Link
Link
Link
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes bookmarks" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
Text [[bookmark]] Text
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
Text Text
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes crossreferences" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
[[reference]]
== Section
Inline Reference to <>
Footnoted Reference to <>
Inline Reference with Text to <>
Footnoted Reference with Text to <>
Anchored Crossreference to other document <>
Capitalised Reference to <>
Lowercase Footnoted Reference to <>
Capitalised Reference to <>
Lowercase Footnoted Reference to <>
Capitalised Reference to <>
Lowercase Footnoted Reference to <>
Capitalised Reference to <>
Lowercase Footnoted Reference to <>
Lowercase Footnoted Reference to <>
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
Section
Inline Reference to
Footnoted Reference to
Inline Reference with Text to text
Footnoted Reference with Text to text
Anchored Crossreference to other document
Capitalised Reference to
Lowercase Footnoted Reference to
Capitalised Reference to
Lowercase Footnoted Reference to
Capitalised Reference to
Lowercase Footnoted Reference to
Capitalised Reference to
Lowercase Footnoted Reference to
Lowercase Footnoted Reference to
text
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.
ReferencexReferenceISO713713
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes footnotes" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
Hello!footnote:[Footnote text]
== Title footnote:[Footnote text 2]
Hello.footnote:abc[This is a repeated footnote]
Repetition.footnote:abc[]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
Foreword
Hello!
Footnote text
Title
Footnote text 2
Hello.
This is a repeated footnote
Repetition.
This is a repeated footnote
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes index terms" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
((See)) Index ((_term_)) and(((A~B~, stem:[alpha], Ⲁ))).
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
SeeSee Index termterm andABⲀ.
OUTPUT
expect((strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to(output)
end
it "processes format-specific inline pass" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
pass-format:rfc,html[X > Y]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
<abc>X > Y</abc>
OUTPUT
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to xmlpp(output)
end
it "processes Metanorma XML inline pass" do
input = <<~INPUT
#{ASCIIDOC_BLANK_HDR}
+X >+ +++Y+++ pass:c[]
INPUT
output = <<~OUTPUT
#{BLANK_HDR}
<abc>X > Y </abc>
OUTPUT
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
.to be_equivalent_to xmlpp(output)
end
end