New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
list sourceMap end row includes trailing blank lines #374
Comments
I think that may be a bug. Usually only top level blocks are used to sync with preview scoll. So, nobody checked what happens in lists. But i don't remember details, need to investigate. |
Brief technical reasoning for the current (possibly incorrect) behavior: End line in List stops on Paragraph stops on a second empty line, because it's guaranteed to terminate a paragraph no matter how many empty lines are after it. I'm not sure what should be in the map, there's a good chance all rules need to be re-checked for this. |
P.S.: this behavior was unintentionally changed in 8.0.0 following CM spec changes. Looking into fixing it now. |
Hmph.. checking CM spec, it probably should behave like this:
should result in But the following:
should yield If the above is correct, then:
line |
It doesn't seem consistent, as we should either count empty lines in all cases or not count them anywhere. CM spec doesn't exactly define any of this because series of empty lines have no effect on the output. |
I've been checking CM reference implementation. They do have source maps, and their behavior matches ours in this particular case. 0 - foo
1 - bar
2
3
4 - baz
5
6 - quux
7
8
9
10 xxxx
11
12
13 yyyy <ul data-sourcepos="1:1-10:0">
<li data-sourcepos="1:1-4:0">
<p data-sourcepos="1:3-1:5">foo</p>
<ul data-sourcepos="2:3-4:0">
<li data-sourcepos="2:3-4:0">bar</li>
</ul>
</li>
<li data-sourcepos="5:1-6:0">
<p data-sourcepos="5:3-5:5">baz</p>
</li>
<li data-sourcepos="7:1-10:0">
<p data-sourcepos="7:3-7:6">quux</p>
</li>
</ul>
<p data-sourcepos="11:1-11:4">xxxx</p>
<p data-sourcepos="14:1-14:4">yyyy</p> As you can see, list has [0,10] which counts empty lines, but paragraphs don't. I think I'll just ask clarification for it on CM issue tracker. |
Just created a new topic here: https://talk.commonmark.org/t/sourcepos-in-lists/2498 |
Wait, we have sourcemap now??? 🎆 🍺 🍻 |
Very limited implementation, restricted by current architecture |
Oh still the block-level sourcemap ha 😃 |
It is like the plugin render mdfile to the sentence one by one ,so how could i use it to realize the enty file out from xx.md to xx.html ..enn,could i through it? |
When generating sourcemap for lists (both
ul
,li
), the trailing blank lines (\s*
) are included thus the end row of the following example isn't1
as usual, but3
:see demo, where both
bullet_list_open
andlist_item_open
have[ 0, 9 ]
The text was updated successfully, but these errors were encountered: