Sourcepos in lists


#1

Consider the following example:

 - foo      


bar


baz

Commonmark with sourcepos enabled renders it like this:

<ul data-sourcepos="1:2-3:0">
<li data-sourcepos="1:2-3:0">foo</li>
</ul>
<p data-sourcepos="4:1-4:3">bar</p>
<p data-sourcepos="7:1-7:3">baz</p>

So - foo list has 3 lines (including 2 empty lines after it). Paragraphs seem to have just their own 1 line each.

Is this the correct behavior?


markdown-it happens to have similar behavior for lists. There is an issue about it opened here: https://github.com/markdown-it/markdown-it/issues/374 .


#2

I feel like possibly sourcemaps should map empty “eaten” spaces as a pseudo element as opposed to attempt to assume the empty space alway belongs to an element. I would only count 2 lines in this list.