Packages

Earmark is a pure-Elixir Markdown converter. It is intended to be used as a library (just call Earmark.as_html), but can also be used as a command-line tool (run mix escript.build first). Output generation is pluggable.

Retired package: Deprecated - Earmark is no longer maintained. Migrate to a replacement, for example MDEx (https://hex.pm/packages/mdex).
Security advisory: This version has known vulnerabilities. View advisories

Current section

Files

Jump to
earmark lib earmark ast renderer footnote_list_renderer.ex
Raw

lib/earmark/ast/renderer/footnote_list_renderer.ex

defmodule Earmark.Ast.Renderer.FootnoteListRenderer do
alias Earmark.Block
import Earmark.Ast.Emitter
@moduledoc false
def render_footnote_list(items) do
emit("div", [
emit("hr"),
emit("ol", _render_footnote_list_items(items))], class: "footnotes")
end
defp _render_footnote_list_items(items) do
items
|> Enum.map(&_render_footnote_list_item/1)
end
defp _render_footnote_list_item(%Block.ListItem{attrs: %{id: [id]}, blocks: [%Block.Para{attrs: atts, lines: lines}]}) do
id1 = String.trim_leading(id, "#")
emit("li", emit("p", lines ++ _render_footnote_backlink(atts)), id: id1)
end
defp _render_footnote_backlink(%{class: _, href: _, title: _}=atts) do
[emit("a", "↩", atts)]
end
end