Keep StartLine/EndLine/StartColumn
Opened this issue · 9 comments
Hi,
I'm using CommonMark.NET for parsing.
I have a converter on top of it, which should present warnings like
invalid link target on line {0} position {1}
I don't think that would be possible with just SourcePosition
and SourceLength
.
It would be possible, you would just have to count the newlines that are before the SourcePosition
.
In fact StartLine
and StartColumn
does not suit this purpose as it only points to the start of the block (for example, paragraph). Since you would need the position of the link itself (as there could be multiple links within the same block) you would have to use SourcePosition
.
How would I count the newlines?
Wouldn't it be easier for me to add StartLine
and StartPosition
to Inline
?
You can try though I would not suggest it. :) It will be easier to use string.IndexOf('\n', previousIndex)
to count the newlines up to the StartPosition
in the source string.
If you are using streams, it will be harder - in this case perhaps you could add the line counter to the parser - it could be a List<int>
containing a sorted list of all newline positions (fill it in BlockMethods.IncorporateLine()
).
Thank you. I am using stream, so I suppose it has to be a change to the parser.
In any case, could you please not remove those properties from Block
?
For now I don't plan to, that will probably happen on v1. I want remove them because I think it gives people the wrong idea on how to use them. Even for the original purpose - to enable synchronized scrolling between the markdown source and generated HTML code in editors - they are useless if someone wants to use wrapped lines...
Hey,
May I remove the Question label? This is more of a request.
I still think that it is wrong to use these properties in any real life applications - can you describe how you are using them?
I believe the top post describes a realistic scenario. I saw an old post on
CommonMark where jgm said that inline elements should get these as well.
On Fri, Dec 18, 2015 at 9:44 PM, Kārlis Gaņģis notifications@github.com
wrote:
I still think that it is wrong to use these properties in any real life
applications - can you describe how you are using them?—
Reply to this email directly or view it on GitHub
#57 (comment)
.
CommonMark.NET should live up to jgm's high expectations 😆