Closed nelsonic closed 5 years ago
In Club Soda we are using earmark
https://hex.pm/packages/earmark
https://github.com/club-soda/club-soda-guide/blob/a7d95752c3144cacbcce800d5420d9bd210e52a8/mix.exs#L53
Searching for "Markdown" on Hex.pm https://hex.pm/packages?search=markdown It is the most popular (by downloads) module for this purpose:
Sorting for Total downloads the popularity is clear (10x more than edown
)
https://hex.pm/packages?search=markdown&sort=total_downloads
earmark
...?Add earmark
to the deps
section of your mix.exs
file:
{ :earmark, "~> 1.3.0" }
After running mix deps.get
you will be able to transform .md
into .html
:
Code:
def transform do
filename = Path.join(File.cwd!, "p/goals.md") # __ENV__.file # "./app.ex"
# IO.puts filename
case File.read(filename) do
{:ok, markdown} -> # do something with the `body`
IO.puts markdown
html_doc = Earmark.as_html!(markdown)
IO.puts html_doc
html_path = Path.join(File.cwd!, "p/goals.html")
File.write!(html_path, html_doc)
{:error, reason} -> # handle the error caused by `reason`
IO.puts reason
end
end
@nelsonic I haven't used anything other than earmark
myself. I see that you ended up choosing earmark
as well. I am just wondering if you looked into edown
or any of the other options?
@RobStallion at the moment earmark
meets my needs/requirements so I have not looked further.
My actual work is to publish a Markdown file as HTML as fast as possible.
As soon as I have new
or more advanced requirements I will investigate why edown
exists ... https://hex.pm/packages/edown
Usually, when there is a "competing" package, it has more or better features. Right now, I don't need anything special, but anyone who has more advanced features should go for it.
I need to parse Markdown and transform it to HTML which hex.pm package should I use?
Suggestions Welcome! 💬