Opened parsing flags to external code #97
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm investigating replacement for Discount in my project (appledoc). Sundown seems like a way to go. Although I could use included html renderer out of the box, I need to preprocess Markdown before that (for detecting cross references for example).
For that to work, I need to do processing inside
normal_text
callback, however I need to work differently whether the text is inside a link or not and the simplest way I found it to work was to open up parsing flags to outside code - basically, I'd assign pointer tosd_markdown
to my renderer opaque struct and check the flags in callbacks. One way would be to make wholesd_markdown
public, but I didn't like that - so basically I refactored it into public/private interface.To prevent breaking existing users code, I renamed what was before
sd_markdown
intosd_markdown_parser
- this is used internally. And then I simply updated the public interfacesd_markdown
to include relevant flags.sd_markdown_parser
includessd_markdown
struct as the first var - hence I can look at pointers to both structs either way. At this point the only flag included isin_link_body
, but that can be extended in the future should the need be. So my code looks like this:Hopefully you'll find additions useful and merge them to main branch - I'd love to be able to use future updates to main branch without the hassle of refactoring above changes every time :) But feel free to close pull request if you find changes not suitable for your audience.