-
Notifications
You must be signed in to change notification settings - Fork 300
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
Make inline parsing extensible #113
Comments
I'm pretty sure I'm not gonna pick this up in the near future. But if someone else wants to have a go at it, I'm willing to mentor. Help wanted :). |
Hi @robinst, I am willing to work on it. However as a newbie of both codebase and Commonmark spec. Just wanna clarify several points first to make sure I m on the same page as you guys.
|
Hi everyone, several commit have been made for let Both parser and doc parser class to accept multiple instances of InlineParser. My next thought would be alter InlineParser interface to make it return a parsing progress object which is similar to Am I on the right track? Plz advise |
Yes, that's the rough idea (similar to block parsers).
Ideally yes.
Not sure about this bit, I think it would still be useful to have a single class for parsing all the inlines. Not sure what to call that though, if we use |
@robinst First of all, thx for the reply.
So more like a new parser Let say having a While all of above is happening under |
Hi everyone, I drafted a sample of how a Basically what have done are first created a new Then from this point onward a specific |
Hello everyone who might be interested in this! I've been able to achieve the customization of inline parsing in my library recently. I won't say it is perfect but it is fairly simple and implemented in a way so it's relatively easy to keep it upstream. The implementation keeps all current logic and the way inline parsing is done in general but introduces At this point I don't think import org.commonmark.internal.Bracket;
import org.commonmark.internal.Delimiter;
import org.commonmark.internal.ReferenceParser;
import org.commonmark.internal.util.Escaping;
import org.commonmark.internal.util.Html5Entities;
import org.commonmark.internal.util.Parsing;
import org.commonmark.internal.inline.AsteriskDelimiterProcessor;
import org.commonmark.internal.inline.UnderscoreDelimiterProcessor; There is also the So, I think that it would be a good thing to move mentioned above classes to public surface. At least it would make possible custom implementations of Any feedback on my solution is welcome and if someone finds it helpful I can convert it to a Java module (currently it is published as an Android library) |
Support for custom inline content parsers has been released in 0.23.0 now, see |
Similar to how custom block parser can be registered today, it would be good to make inline parsing extensible as well. One use would be to improve autolinking, see #112.
The way this could work:
To support autolinking, a custom inline parser would also need to be able to get the text before the matching character, probably all the plain text characters up to that point. It would also need a way to detect if any brackets are active or not ("are we inside a link?").
The text was updated successfully, but these errors were encountered: