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

Link resolution plugin point #45

Closed
dwaite opened this issue Feb 5, 2015 · 4 comments
Closed

Link resolution plugin point #45

dwaite opened this issue Feb 5, 2015 · 4 comments
Labels

Comments

@dwaite
Copy link

dwaite commented Feb 5, 2015

I'm looking at making a plugin for the wintersmith static site generator to use markdown-it rather than marked.

One feature wintersmith has is the ability to link to pre-build content, and have the link be rewritten while building the static content to be a correct link to the final location. It adds this functionality by patching marked.

Is this something that markdown-it would consider adding as a proper feature?

@puzrin
Copy link
Member

puzrin commented Feb 5, 2015

https://github.com/markdown-it/markdown-it/blob/master/docs/architecture.md#renderer

You can override existing renderer, this feature already exists.

@puzrin puzrin added the question label Feb 5, 2015
@dwaite
Copy link
Author

dwaite commented Feb 6, 2015

Is the proper way to do this to override link_open (and image) in the renderer with a version that resolves the url?

It seems more appropriate to modify the token data at an earlier stage, so that any other custom rules will get resolved URLs.

@puzrin
Copy link
Member

puzrin commented Feb 6, 2015

You can do it in core chain too. https://github.com/markdown-it/markdown-it-for-inline

It's up to you - depends on your needs.

@dwaite
Copy link
Author

dwaite commented Feb 6, 2015

I overrode link_open, but am only modifying the token and passing control on. I'll modify image after I refactor the code.

This should let other overrides work as long as the ordering is correct.
https://github.com/dwaite/wintersmith-markdown-it/blob/master/index.coffee#L28-L55

@dwaite dwaite closed this as completed Feb 6, 2015
GerHobbelt pushed a commit to GerHobbelt/markdown-it that referenced this issue Apr 24, 2017
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