View Source TPK Common Cheat Sheet
usage
Usage
mix-exs
mix.exs
Append the following line to your mix.deps
{:tpk_common, ~> "0.0"}
functions
Functions
earmark-wrapper
Earmark wrapper
Interpret a string as markdown ...
TPK.Common.HTML.md_to_html!("some **bold** text")
Read markdown text from file ...
TPK.Common.HTML.md_file_to_html!("markdown.md")
usage-1
Usage
Import the function to your view or liveview model with
defmodule MyModule do
import TPK.Common.HTML, only: [ md_to_html!: 1 ]
@md_text File.read!("markdown.md")
...
end
Then use the function in your heex-files like so
<%= md_to_html!(@md_text) %>
You may read from files directely with
TPK.Common.HTML.md_file_to_html!("README.md")