Sha256: 1bfac26993aff390bfd2c29bd629f95112cbb28eaf0ee8f2edfb76a9b7dadd90

Contents?: true

Size: 1.61 KB

Versions: 10

Compression:

Stored size: 1.61 KB

Contents

require 'spec_helper'

describe ReverseAsciidoctor::Converters::Pre do

  let(:converter) { ReverseAsciidoctor::Converters::Pre.new }

  it 'converts as literal' do
    node = node_for("<pre>puts foo</pre>")
    expect(converter.convert(node)).to include "....\nputs foo\n....\n"
  end

  it 'converts as literal with anchor' do
    node = node_for("<pre id='A'>puts foo</pre>")
    expect(converter.convert(node)).to include "[[A]]\n....\nputs foo\n....\n"
  end

  it 'preserves new lines' do
    node = node_for("<pre>foo\nbar</pre>")
    expect(converter.convert(node)).to include "....\nfoo\nbar\n....\n"
  end

  it 'preserves xml' do
    node = node_for("<pre><code>x</code><br/><p>hello</p></pre>")
    expect(converter.convert(node)).to include "....\n<code>x</code><br><p>hello</p>\n....\n"
  end

  context 'syntax highlighting' do
    it 'works for "highlight-lang" mechanism' do
      div = node_for("<div class='highlight highlight-ruby'><pre>puts foo</pre></div>")
      pre = div.children.first
      expect(converter.convert(pre)).to include "[source,ruby]\n----\nputs foo\n----\n"
    end

    it 'works for the confluence mechanism' do
      pre = node_for("<pre class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
      expect(converter.convert(pre)).to include "[source,html/xml]\n----\nputs foo\n----\n"
    end

    it 'works for the confluence mechanism, with anchor' do
      pre = node_for("<pre id = 'A' class='theme: Confluence; brush: html/xml; gutter: false'>puts foo</pre>")
      expect(converter.convert(pre)).to include "[[A]]\n[source,html/xml]\n----\nputs foo\n----\n"
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
reverse_adoc-0.2.8 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_adoc-0.2.7 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_adoc-0.2.6 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_adoc-0.2.5 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_adoc-0.2.4 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_adoc-0.2.3 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_asciidoctor-0.2.2 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_asciidoctor-0.2.1 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_asciidoctor-0.2.0 spec/lib/reverse_asciidoctor/converters/pre_spec.rb
reverse_asciidoctor-0.1.0 spec/lib/reverse_asciidoctor/converters/pre_spec.rb