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

[Documentation] Display an example for a local .md file #735

Open
rubyFeedback opened this issue Apr 9, 2023 · 1 comment
Open

[Documentation] Display an example for a local .md file #735

rubyFeedback opened this issue Apr 9, 2023 · 1 comment

Comments

@rubyFeedback
Copy link

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
@arashster
Copy link

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants