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.

Current status:

Values

pub fn configure() -> document.Options

Configure default options for mork.

Example usage:

let doc = mork.configure()
  |> mork.strip_frontmatter(True)
  |> mork.parse_with_options(markdown)
let html = doc |> mork.to_html
pub fn document_to_html(doc: document.Document) -> String

Convert a Document structure to HTML. This alias exists for compatibility with jot.

pub fn emojis(
  opt: document.Options,
  enable emojis: Bool,
) -> document.Options

Toggle support for Emoji short codes Note: Disabled by default.

pub fn extended(
  opt: document.Options,
  enable on: Bool,
) -> document.Options

Enable or disable all extended features at once.

Example usage:

let doc = mork.configure()
  |> mork.extended(True)
  |> 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. See https://www.markdownguide.org/extended-syntax/#footnotes

pub fn heading_ids(
  opt: document.Options,
  enable heading_ids: Bool,
) -> document.Options

Toggle support for Heading IDs. Note: Disabled by default. See https://www.markdownguide.org/extended-syntax/#heading-ids

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 split_frontmatter_from_input(
  input: String,
) -> #(String, String)

Extract frontmatter from input if present. The frontmatter section MUST begin at the beginning of the input with a — line and end with a — line. See https://jekyllrb.com/docs/front-matter/

pub fn strip_frontmatter(
  opt: document.Options,
  enable strip_frontmatter: Bool,
) -> document.Options

Strip YAML frontmatter from the markdown input. Note: Disabled by default. See https://jekyllrb.com/docs/front-matter/

pub fn tables(
  opt: document.Options,
  enable tables: Bool,
) -> document.Options

Toggle support for Tables / Github Flavored Markdown Note: Disabled by default. See https://github.github.com/gfm

pub fn tasklists(
  opt: document.Options,
  enable tasklists: Bool,
) -> document.Options

Toggle support for Tasklisks / Github Flavored Markdown Note: Disabled by default. See https://github.github.com/gfm

pub fn to_html(doc: document.Document) -> String

Convert a Document structure to HTML.

Search Document