Skip to content
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

Keep StartLine/EndLine/StartColumn #57

Open
dmitry-shechtman opened this issue Nov 24, 2015 · 9 comments
Open

Keep StartLine/EndLine/StartColumn #57

dmitry-shechtman opened this issue Nov 24, 2015 · 9 comments
Labels

Comments

@dmitry-shechtman
Copy link
Contributor

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.

@Knagis
Copy link
Owner

Knagis commented Nov 24, 2015

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.

@dmitry-shechtman
Copy link
Contributor Author

How would I count the newlines?

Wouldn't it be easier for me to add StartLine and StartPosition to Inline?

@Knagis
Copy link
Owner

Knagis commented Nov 24, 2015

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()).

@dmitry-shechtman
Copy link
Contributor Author

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?

@Knagis
Copy link
Owner

Knagis commented Nov 24, 2015

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...

@dmitry-shechtman
Copy link
Contributor Author

Hey,

May I remove the Question label? This is more of a request.

@Knagis
Copy link
Owner

Knagis commented Dec 18, 2015

I still think that it is wrong to use these properties in any real life applications - can you describe how you are using them?

@dmitry-shechtman
Copy link
Contributor Author

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 [email protected]
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)
.

@dmitry-shechtman
Copy link
Contributor Author

commonmark/cmark#26

CommonMark.NET should live up to jgm's high expectations 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants