-
-
Notifications
You must be signed in to change notification settings - Fork 396
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
Having README.md work for GitHub and Yard #1017
Comments
Don't override the renderer. Instead, create your own renderer and register it as a markup type: https://github.com/lsegal/yard/blob/master/lib/yard/templates/helpers/markup_helper.rb#L25-L32 helper = YARD::Templates::Helpers::MarkupHelper
helper.clear_markup_cache
helper::MARKUP_PROVIDERS[:markdown].unshift const: 'MyMarkdown' Markup classes just need to implement a constructor and class MyMarkdown
attr_reader :to_html
def initialize(text)
renderer = MyRenderHTML.new
markdown = Redcarpet::Markdown.new(renderer, no_intra_emphasis: true, ...)
@to_html = markdown.render(text)
end
end Hope that helps. |
I just edited the above snippet (registering the provider) to be more accurate. Previous snippet would not work correctly. Also simplified the markdown provider implementation. |
Marking this as closed since the above should answer the question. Feel free to re-open if you have others. |
@lsegal Hey, it's not clear to me where the best place to bootstrap this is?
I was hoping to do something similar to this. |
@keithharvey did you ever figure it out? It's not clear from the docs where to "hook in" or "bootstrap" custom overrides in Ruby like this. |
The only thing I've come up with that seems to work in all contexts is defining an unpublished
|
I would like to use a different render than #html_markup_markdown uses by default.
Steps to reproduce
You see 2 different types of entries in README.md files
or
In the first case the link works for Yard but not for GitHub. In the second case it works for GitHub, but you get a file not found error in Yard.
The code below allows markdown links to be put in extra files and for the links to be fixed when Yard runs. However I find this rather inelegant and would prefer a better solution.
Any hints on how to proceed would be appreciated.
I have read the Contributing Guide.
The text was updated successfully, but these errors were encountered: