-
-
Notifications
You must be signed in to change notification settings - Fork 255
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
Various Extension System Problems #79
Comments
It was first ported from marked.js. This is why it follows the design of marked. I've noticed it is hard to be extended #62 |
Yeah. It's quite disappointing :( If you want some more concrete advise on how to do it I can probably outline some general suggestions. |
@mitsuhiko That would be helpful. I am not good at writing parsers. |
Goddammit :) Do you have some text messenger? Easier than issue trackers for this sort of stuff. |
@mitsuhiko How about https://telegram.me/lepture |
I investigated the re module a bit for that purpose and discovered how the undocumented |
@lepture @mitsuhiko Any progress on this? I've been toying around with @mitsuhiko's scanner and got a basic parser working (no extensions yet). The only issue so far is backreferences seem to not work, so it's probably not possible to avoid breaking changes in mistune. |
@nitely not yet. |
Hey @lepture , I'm don't know how advanced this re-implementation is, but I wanted to share what I have so far[0], since I'm not planning to ever releasing it as a library. It might serve you as inspiration. Every element is implemented as an extension, so it should be highly extensible. The text is parsed, then an AST is generated, then the AST is rendered as HTML. A different render can be easily implemented as well. I've written it a while ago, but IIRC, it's able to correctly parse daring fireball examples and docs. Benchmarks shows it's as fast as mistune. [0] https://gist.github.com/nitely/9fe34f64cd300aaa92af731f5634ce8b |
@nitely Thanks for sharing. Scanner is different in Python 2 and Python 3, that's why I'm hesitated to implement it in scanner. Currently my focus is on other projects, so that this will be hold on for a while. |
NP 😺
mmh it is. But still works in py2 and py3 (the code I shared is for py3). I made a PR for fixing the original @mitsuhiko code mitsuhiko/python-regex-scanner#3 .
Yeah, no problem. mistune is actually good enough for me at its current state. |
v2 is ready now. |
I just looked at how the grammar is extended and in it's current form it's not really usable. There are a few problems with the way the inline lexer is supposed to modified alone:
default_rules
which is a class attribute and as such shared across all other lexers as well.text
rule is greedy it needs to be modified whenever another rule is inserted but it is impossible for a plugin to do so because it cannot now which sequences indicate the start of a rule. The current example only works by chance.I think the current design does not really suit itself to extension well but I'm not sure how to fix it without breaking what's already there.
The text was updated successfully, but these errors were encountered: