Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asciidoctor: Handle skipped lines #643

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,13 @@ def reader.process_line(line)

@in_attribute_only_block = true
line.clear
elsif SOURCE_WITH_SUBS_RX =~ line
line = super
line.sub! "subs=\"#{$1}\"", "subs=\"#{$1},callouts\"" unless $1.include? 'callouts'
else
line = super
return nil if line.nil?

if SOURCE_WITH_SUBS_RX =~ line
line.sub! "subs=\"#{$1}\"", "subs=\"#{$1},callouts\"" unless $1.include? 'callouts'
end
if CODE_BLOCK_RX =~ line
if @code_block_start
if line != @code_block_start
Expand Down
63 changes: 63 additions & 0 deletions resources/asciidoctor/spec/elastic_compat_preprocessor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@
DOCBOOK
expect(actual).to eq(expected.strip)
end

it "doesn't mind skipped #{name} block macros" do
actual = convert <<~ASCIIDOC
== Example

ifeval::["true" == "false"]
#{name}[some_version]
#endif::[]
ASCIIDOC
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>

</chapter>
DOCBOOK
expect(actual).to eq(expected.strip)
end
end

it "invokes include-tagged::" do
Expand Down Expand Up @@ -210,6 +227,33 @@
expect(actual).to eq(expected.strip)
end

it "doesn't mind skipped source blocks that are missing callouts" do
actual = convert <<~ASCIIDOC
== Example

ifeval::["true" == "false"]
["source","sh",subs="attributes"]
--------------------------------------------
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.zip
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-{version}.zip.sha512
shasum -a 512 -c elasticsearch-{version}.zip.sha512 <1>
unzip elasticsearch-{version}.zip
cd elasticsearch-{version}/ <2>
--------------------------------------------
<1> Compares the SHA of the downloaded `.zip` archive and the published checksum, which should output
`elasticsearch-{version}.zip: OK`.
<2> This directory is known as `$ES_HOME`.
endif::[]
ASCIIDOC
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>

</chapter>
DOCBOOK
expect(actual).to eq(expected.strip)
end

it "fixes mismatched fencing on code blocks" do
input = <<~ASCIIDOC
== Example
Expand All @@ -227,6 +271,25 @@
expect(actual).to eq(expected.strip)
end

it "doesn't doesn't mind skipped mismatched code blocks" do
actual = convert <<~ASCIIDOC
== Example

ifeval::["true" == "false"]
----
foo
--------
endif::[]
ASCIIDOC
expected = <<~DOCBOOK
<chapter id="_example">
<title>Example</title>

</chapter>
DOCBOOK
expect(actual).to eq(expected.strip)
end

it "doesn't break table-style outputs" do
actual = convert <<~ASCIIDOC
== Example
Expand Down