lottia.net's ex-markdown fork, targeting current Comrak https://gitlab.com/nathanfaucett/ex-markdown
This repository has been archived on 2024-03-22. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Amelia Cuss 0cf9a44cb6 README: link to canonical source. 2024-01-18 17:49:57 +11:00
config config.exs: address deprecation. 2024-01-01 22:26:31 +11:00
lib comrak: use akkoma branch, add akkoma_autolinks option. 2024-01-11 23:32:45 +11:00
native/comrak_rustler v0.1.5 2024-01-11 23:56:57 +11:00
test lib: support native renderer, cleanup. 2024-01-03 23:20:23 +11:00
.formatter.exs Initial commit 2018-03-29 19:26:20 -05:00
.gitignore all: clean up, latest versions, building. 2024-01-02 14:06:44 +11:00
.gitlab-ci.yml gitlab ci 2018-03-30 20:55:46 -05:00
LICENSE LICENSE: chmod -x. 2024-01-02 02:27:42 +11:00
README.md README: link to canonical source. 2024-01-18 17:49:57 +11:00
flake.lock all: clean up, latest versions, building. 2024-01-02 14:06:44 +11:00
flake.nix v0.1.5 2024-01-11 23:56:57 +11:00
mix.exs v0.1.5 2024-01-11 23:56:57 +11:00
mix.lock all: clean up, latest versions, building. 2024-01-02 14:06:44 +11:00
mix.nix all: clean up, latest versions, building. 2024-01-02 14:06:44 +11:00

Note: This README is currently out-of-date, but this fork isn't!


Markdown

markdown renderer for comrak markdown parser

Installation

If available in Hex, the package can be installed by adding markdown to your list of dependencies in mix.exs:

def deps do
  [
    {:markdown, "~> 0.1"}
  ]
end

Usage

# (markdown[, Renderer \\ Markdown.HtmlRenderer][, data \\ %{}])
Markdown.render("# Hello, world")

Custom Renderers

defmodule MyModule.CustomRenderer do
  use Markdown.Renderer

  def block_code(_data, code, lang) do
  	"<pre><code class=\"language-#{lang} #{lang}\">#{HtmlEntities.encode(code)}</code></pre>"
  end
end

Overrides

Block

block_code(data, code, lang)
block_quote(data, quote)
block_html(data, raw_html)
footnotes(data, content)
footnote_def(data, content, number)
footnote_ref(data, number)
header(data, text, header_level)
hrule(data)
list(data, contents, list_type, start)
list_item(data, text, list_type)
paragraph(data, text)
table(data, header, body)
table_row(data, content)
table_cell(data, content, alignment, header)

Inline

codespan(data, code)
double_emphasis(data, text)
emphasis(data, text)
image(data, url, title, alt_text)
linebreak(data)
softbreak(data)
link(data, url, title, content)
raw_html(data, raw_html)
triple_emphasis(data, text)
strikethrough(data, text)
superscript(data, text)
underline(data, text)
highlight(data, text)
quote(data, text)

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/markdown.