Sha256: 33e57a3e6a091508d25769292857ccb4500d3c4b6124531496d6bbce2c5190b1

Contents?: true

Size: 1.96 KB

Versions: 8

Compression:

Stored size: 1.96 KB

Contents

require 'test_helper'

class TestAttributes < Minitest::Test
  def setup
    contents = File.read(File.join(FIXTURES_DIR, 'dingus.md'))
    @doc = CommonMarker.render_doc(contents.strip)
  end

  def test_sourcepos
    sourcepos = []

    @doc.walk do |node|
      sourcepos << node.sourcepos
    end

    sourcepos.delete_if { |h| h.values.all? { |v| v == 0 } }

    result = [
      {
        :start_line => 1,
        :start_column => 1,
        :end_line => 10,
        :end_column => 12
      },
      {
        :start_line => 1,
        :start_column => 4,
        :end_line => 1,
        :end_column => 17
      },
      {
        :start_line => 3,
        :start_column => 1,
        :end_line => 5,
        :end_column => 36
      },
      {
        :start_line => 7,
        :start_column => 1,
        :end_line => 10,
        :end_column => 12
      },
      {
        :start_line => 7,
        :start_column => 1,
        :end_line => 7,
        :end_column => 11
      },
      {
        :start_line => 7,
        :start_column => 4,
        :end_line => 7,
        :end_column => 11
      },
      {
        :start_line => 8,
        :start_column => 1,
        :end_line => 10,
        :end_column => 12
      },
      {
        :start_line => 8,
        :start_column => 4,
        :end_line => 8,
        :end_column => 11
      },
      {
        :start_line => 9,
        :start_column => 4,
        :end_line => 10,
        :end_column => 12
      },
      {
        :start_line => 9,
        :start_column => 4,
        :end_line => 9,
        :end_column => 12
      },
      {
        :start_line => 9,
        :start_column => 6,
        :end_line => 9,
        :end_column => 12
      },
      {
        :start_line => 10,
        :start_column => 4,
        :end_line => 10,
        :end_column => 12
      },
      {
        :start_line => 10,
        :start_column => 6,
        :end_line => 10,
        :end_column => 12
      }
    ]

    assert_equal result, sourcepos
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
commonmarker-0.9.2 test/test_attributes.rb
commonmarker-0.9.1 test/test_attributes.rb
commonmarker-0.9.0 test/test_attributes.rb
commonmarker-0.8.0 test/test_attributes.rb
commonmarker-0.7.0 test/test_attributes.rb
commonmarker-0.6.0 test/test_attributes.rb
commonmarker-0.5.1 test/test_attributes.rb
commonmarker-0.5.0 test/test_attributes.rb