Skip to content

Latest commit

 

History

History
82 lines (67 loc) · 1.64 KB

README.md

File metadata and controls

82 lines (67 loc) · 1.64 KB

Markbug

A fast markdown parser in pure Elixir, without using regular expressions.

The parser, as of testing, is 10x faster than Earmark for longer documents; with comparable performance to MDex, a Rust NIF.

Installation

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

def deps do
  [
    {:markbug, "~> 0.9.0"}
  ]
end

Basic Usage

iex> Markbug.ast("""
# Foo Bar

_According to all known laws of aviation_, *there is no way a bee should be able to fly*.
""")

{:ok,
 [
   {:header, 1, [text: "Foo Bar"]},
   {:p,
    [
      {:em, 95, ["According to all known laws of aviation"]},
      ", ",
      {:em, 42, ["there is no way a bee should be able to fly"]},
      "."
    ]}
 ]}
iex> Markbug.html("""
# Foo Bar
 
_According to all known laws of aviation_, *there is no way a bee should be able to fly*.
""")

[
  ["<", "article", ">"],
  [
    [["<", "h1", ">"], ["Foo Bar"], ["</", "h1", ">"]],
    [
      ["<", "p", ">"],
      [
        [
          ["<", "i", ">"],
          ["According to all known laws of aviation"],
          ["</", "i", ">"]
        ],
        ", ",
        [
          ["<", "b", ">"],
          ["*", ["there is no way a bee should be able to fly"], "*"],
          ["</", "b", ">"]
        ],
        "."
      ],
      ["</", "p", ">"]
    ]
  ],
  ["</", "article", ">"]
]

Notes

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