View Source MDEx (MDEx v0.1.5)
A fast 100% CommonMark-compatible GitHub Flavored Markdown parser and formatter.
Use Rust's comrak crate under the hood.
Summary
Functions
Convert markdown
to HTML.
Examples
iex> MDEx.to_html("# MDEx")
"<h1>MDEx</h1>\n"
iex> MDEx.to_html("Implemented with:\n1. Elixir\n2. Rust")
"<p>Implemented with:</p>\n<ol>\n<li>Elixir</li>\n<li>Rust</li>\n</ol>\n"
Convert markdown
to HTML with custom opts
.
Options
Accepts all available Comrak Options as keyword lists.
:extension
- https://docs.rs/comrak/latest/comrak/struct.ComrakExtensionOptions.html:parse
- https://docs.rs/comrak/latest/comrak/struct.ComrakParseOptions.html:render
- https://docs.rs/comrak/latest/comrak/struct.ComrakRenderOptions.html:features
- see the available options below.
Features Options
:sanitize
(defaultfalse
) - sanitize output using ammonia. Recommended if passingrender: [unsafe_: true]
:syntax_highlighting
(default"InspiredGithub
) - syntax highlight code fences using syntect. See a list of available themes at struct.ThemeSet
Examples
iex> MDEx.to_html("# MDEx")
"<h1>MDEx</h1>\n"
iex> MDEx.to_html("Implemented with:\n1. Elixir\n2. Rust")
"<p>Implemented with:</p>\n<ol>\n<li>Elixir</li>\n<li>Rust</li>\n</ol>\n"
iex> MDEx.to_html("Hello ~world~ there", extension: [strikethrough: true])
"<p>Hello <del>world</del> there</p>\n"
iex> MDEx.to_html("<marquee>visit https://https://beaconcms.org</marquee>", extension: [autolink: true], render: [unsafe_: true])
"<p><marquee>visit <a href=\"https://https://beaconcms.org\">https://https://beaconcms.org</a></marquee></p>\n"
iex> MDEx.to_html("# Title with <script>console.log('dangerous script')</script>", render: [unsafe_: true], features: [sanitize: true])
"<h1>Title with </h1>\n"