mork
Mörk is a Markdown parser for Gleam that should work in both Erlang and Javascript contexts.
The goal is 100% spec compliance with Commonmark, as well as supporting GFM (Github Flavored Markdown) extensions like footnotes.
Status right now is that it is entirely unusable and experimental. To see what the current state of the parser is, see the test suite.
Values
pub fn configure() -> document.Options
Configure default options for mork.
Example usage:
let doc = mork.configure()
|> mork.strip_frontmatter
|> mork.parse_with_options(markdown)
let html = doc |> mork.to_html
pub fn footnotes(
opt: document.Options,
enable footnotes: Bool,
) -> document.Options
Toggle support for footnote syntax. Note: Footnotes are enabled by default.
pub fn parse(input input: String) -> document.Document
Parse a string containing Markdown into a Document record. Document can be turned into HTML using the to_html function.
import mork
pub fn main() {
let md = "# hello world\n"
let html = md
|> mork.parse
|> mork.to_html
io.print(html)
}
pub fn parse_debug(
md: String,
callback: fn(String) -> Nil,
) -> document.Document
pub fn parse_with_options(
options options: document.Options,
input input: String,
) -> document.Document
Parse a Markdown document into a Document record
with the given options.
For an example on how to use this, see configure.
pub fn strip_frontmatter(
opt: document.Options,
) -> document.Options
Strip YAML frontmatter from the markdown input. See https://jekyllrb.com/docs/front-matter/