Sha256: d06a4417a8657ff7a2f81cc8897d9e2cc4c4bef42f7d0f1e988666fa180d19b6

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require('test_helper')

class TestQfmCodeDataMetadata < Minitest::Test
  def test_to_html
    text = <<~MD
      ```ruby:example main.rb
      puts :foo
      ```
    MD
    doc = render_doc(text)
    expected = <<~HTML
      <pre><code data-metadata="ruby:example main.rb">puts :foo
      </code></pre>
    HTML

    assert_equal(expected, doc.to_html(:CODE_DATA_METADATA))
    assert_equal(expected, QiitaMarker::HtmlRenderer.new(options: :CODE_DATA_METADATA).render(doc))
  end

  def test_with_character_reference
    text = <<~MD
      ```ruby:example&#x20;main.rb
      puts :foo
      ```
    MD
    doc = render_doc(text)
    expected = <<~HTML
      <pre><code data-metadata="ruby:example main.rb">puts :foo
      </code></pre>
    HTML

    assert_equal(expected, doc.to_html(:CODE_DATA_METADATA))
    assert_equal(expected, QiitaMarker::HtmlRenderer.new(options: :CODE_DATA_METADATA).render(doc))
  end

  def render_doc(markdown)
    QiitaMarker.render_doc(markdown, :DEFAULT, [])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qiita_marker-0.23.2.3 test/test_qfm_code_data_metadata.rb
qiita_marker-0.23.2.2 test/test_qfm_code_data_metadata.rb