redcarpet
redcarpet copied to clipboard
[Documentation] Display an example for a local .md file
I am trying to find alternatives to kramdown right now because I have some odd problem with it - can't use it in .cgi scripts for instance. No clue why.
So redcarpet seemed like an alternative.
The documentation has this:
# Initializes a Markdown parser
markdown = Redcarpet::Markdown.new(renderer, extensions = {})
The documentation claims Redcarpet is easy to use. But I can not copy/paste the example as-is. It tells me I need to pass a renderer but what is that even? It is not clear from the documentation.
Could someone please add a simple example how to evaluate the markdown from an existing .md file? In general all the "this is simple to use" would be better served by replacing all such cases with specific examples. Now I have to look at some other files in order to find out how to do this.
kramdown on the other hand makes this super easy:
puts Kramdown::Document.new(File.read("example.md")).to_html
It appears like the "renderer" gets passed in as one of the renderers that are already built (or you can extend your own), for example:
markdown = Redcarpet::Markdown.new(
Redcarpet::Render::HTML,
autolink: true,
tables: true,
hard_wrap: true
)