Sha256: e46cb92fbd1a091980c22f883ccea641ee4666d95873b0885f828abc712601dd

Contents?: true

Size: 1.7 KB

Versions: 10

Compression:

Stored size: 1.7 KB

Contents

require 'spec_helper'

describe ReverseAsciidoctor::Converters::Text do

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

  it 'treats newline within text as a single whitespace' do
    input = node_for("<p>foo\nbar</p>")
    result = converter.convert(input)
    expect(result).to eq 'foo bar'
  end

  it 'removes leading newlines' do
    input = node_for("<p>\n\nfoo bar</p>")
    result = converter.convert(input)
    expect(result).to eq 'foo bar'
  end

  it 'removes trailing newlines' do
    input = node_for("<p>foo bar\n\n</p>")
    result = converter.convert(input)
    expect(result).to eq 'foo bar'
  end

  it 'keeps nbsps' do
    input = node_for("<p>foo\u00A0bar \u00A0</p>")
    result = converter.convert(input)
    expect(result).to eq "foo&nbsp;bar &nbsp;"
  end

  it 'keeps escaped HTML-ish characters' do
    input = node_for("<p>&lt;foo&gt;</p>")
    result = converter.convert(input)
    expect(result).to eq '\<foo\>'
  end

  context 'within backticks' do
    it "preserves single underscores" do
      input = node_for("<p>`foo_bar`</p>")
      result = converter.convert(input)
      expect(result).to eq '`foo_bar`'
    end

    it "preserves multiple underscores" do
      input = node_for("<p>`foo_bar __example__`</p>")
      result = converter.convert(input)
      expect(result).to eq '`foo_bar __example__`'
    end

    it "preserves single asterisks" do
      input = node_for("<p>`def foo *args`</p>")
      result = converter.convert(input)
      expect(result).to eq '`def foo *args`'
    end

    it "preserves multiple asterisks" do
      input = node_for("<p>`def foo 2***3`</p>")
      result = converter.convert(input)
      expect(result).to eq '`def foo 2***3`'
    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/text_spec.rb
reverse_adoc-0.2.7 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_adoc-0.2.6 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_adoc-0.2.5 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_adoc-0.2.4 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_adoc-0.2.3 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_asciidoctor-0.2.2 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_asciidoctor-0.2.1 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_asciidoctor-0.2.0 spec/lib/reverse_asciidoctor/converters/text_spec.rb
reverse_asciidoctor-0.1.0 spec/lib/reverse_asciidoctor/converters/text_spec.rb