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

Expose source position to scanners and extensions #53

Open
aleator opened this issue Jul 5, 2018 · 5 comments
Open

Expose source position to scanners and extensions #53

aleator opened this issue Jul 5, 2018 · 5 comments

Comments

@aleator
Copy link

aleator commented Jul 5, 2018

Would it be possible to expose the source position for scanners and extension building functions? I have two use cases that would greatly benefit from this:

  1. Many extensions can fail on bad markup. Currently, when this happens it can be really hard find out where it happened. For example, I would like to typecheck my code examples.

  2. Wiki like editing would benefit from this as it would allow the generated html to point at the original source

I did notice that this was mentioned in the documentation. You can count this issue as a vote for adding the source locations + an offer to do some of the work.

@mrkkrp
Copy link
Member

mrkkrp commented Jul 5, 2018

This would require also adding a proper way for extensions to signal failure.

@aleator
Copy link
Author

aleator commented Jul 6, 2018

I think raising an exception would be sufficient.

@mrkkrp
Copy link
Member

mrkkrp commented Jul 7, 2018

Well I think it's not the best way to solve the problem, mostly because this

  • Can be handled "purely", i.e. without exceptions.
  • I'm not a big fan of throwing exceptions from pure code.
  • This does not allow us combine and report multiple errors at once, which is something we could reasonably expect from a tool with already such a good story with respect to error reporting.

So for now throwing is an option because the code is written as it's written, but I think we should improve this in the future, or at least try to.

@aleator
Copy link
Author

aleator commented Jul 11, 2018

I agree on all of your points. However, I think that the error handling depends on the source position, so the latter would be best to implement first. If I'd submit a patch to add source position / span for code blocks and inline urls would that make for acceptable first step?

@mrkkrp
Copy link
Member

mrkkrp commented Jul 12, 2018

Well you could try, but my understanding is that it's not trivial to get quite right and it may make the parser slower. Be prepared that I may be picky about the solution.

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

No branches or pull requests

2 participants