diff --git a/resources/asciidoctor/lib/elastic_compat_tree_processor/extension.rb b/resources/asciidoctor/lib/elastic_compat_tree_processor/extension.rb index 70c3017b53880..4f5848c681455 100644 --- a/resources/asciidoctor/lib/elastic_compat_tree_processor/extension.rb +++ b/resources/asciidoctor/lib/elastic_compat_tree_processor/extension.rb @@ -67,7 +67,13 @@ def process_subs(block) }.freeze def process_lang_override(block) - next_block = block.next_adjacent_block + # Check if the next block is a marker for the language + # We don't want block.next_adjacent_block because that'll go "too far" + # and it has trouble with definition lists. + my_index = block.parent.blocks.find_index block + return unless my_index + + next_block = block.parent.blocks[my_index + 1] return unless next_block && next_block.context == :paragraph return unless next_block.source =~ %r{pass:\[//\s*([^:\]]+)(?::\s*([^\]]+))?\]} diff --git a/resources/asciidoctor/spec/elastic_compat_tree_processor_spec.rb b/resources/asciidoctor/spec/elastic_compat_tree_processor_spec.rb index 04ba3a3d23b6c..98efeb0a9c5fc 100644 --- a/resources/asciidoctor/spec/elastic_compat_tree_processor_spec.rb +++ b/resources/asciidoctor/spec/elastic_compat_tree_processor_spec.rb @@ -96,4 +96,27 @@ expect(actual).to eq(expected.strip) end end + + context 'a snippet is inside of a definition list' do + let(:converted) do + convert <<~ASCIIDOC + == Example + Term:: + Definition + + + -- + [source,js] + ---- + GET / + ---- + -- + ASCIIDOC + end + let(:has_original_language) do + %r{GET /} + end + it "doesn't break" do + expect(converted).to match(has_original_language) + end + end end