Skip to content

Incorrect line numbering/location information when certain unicode characters are used #158

Closed
@mivok

Description

@mivok

This is a strange one:

$ cat testcase.rb
#!/usr/bin/env ruby
require 'kramdown'
text = <<EOF
nbsp nbsp (the first space on this line is unicode 0xA0 - a non-breaking space)

- Test

# Test
EOF

doc = Kramdown::Document.new(text).root
puts doc.children.inspect

$ ./testcase.rb
[<kd:p nil {:location=>1} [<kd:text "nbsp nbsp" nil>]>, <kd:blank "\n" nil>, <kd:ul nil {:location=>3} [<kd:li nil {:location=>3} [<kd:p nil {:location=>3, :transparent=>true} [<kd:text "Test" nil>]>]>]>, <kd:blank "\n" nil>, <kd:header nil {:level=>1, :raw_text=>"Test", :location=>6} [<kd:text "Test" nil>]>]

The location for the header is parsed as line 6, when it should be line 5. Interestingly, the location for the list item is shown as line 3, which is correct.

This came from a much larger markdown document, and I managed to get it down to that small test case while still reproducing the issue.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions