# mork
[](https://hex.pm/packages/mork)
[](https://hexdocs.pm/mork/)
[](https://brainmade.org)
__MÖRK__ is a Markdown parser written in pure Gleam. It is 100% spec compliant
with Commonmark, supports most Github extensions, some Obsidian extensions and footnotes.
It has mainly been developed for the Erlang compilation target, but is tested
against and should work for both Node.js, Deno and Bun as Javascript runtimes.
Though to be fair, for someone targetting Javascript the commonmark.js library
is probably faster (though it doesn't support the features of Mörk).
## Status
- All Commonmark spec tests are passing.
- Footnotes are supported.
- Most GFM (Github) features are supported.
- Some Obsidian features are supported.
- See [TODO.md](https://git.liten.app/krig/mork/src/branch/main/TODO.md) for details on extended syntax support.
## Example
```sh
gleam add mork@1
```
```gleam
import simplifile
import mork
pub fn main() -> Nil {
let readme = "./README.md"
let assert Ok(markdown) = simplifile.read(from: readme)
let html = markdown |> mork.parse |> mork.to_html
let assert Ok(_) = html |> simplifile.write(to: "README.html")
}
```
Further documentation can be found at <https://hexdocs.pm/mork>.
## Lustre support
There is an experimental Lustre support package called `mork_to_lustre`:
```sh
gleam add mork_to_lustre
```
```gleam
import mork
import mork/to_lustre
pub fn main() -> Nil {
let markdown = "# Hello, Joe!\n"
let e = markdown |> mork.parse |> to_lustre.to_lustre
let e = e |> element.fragment |> element.to_string
assert e == "<h1>Hello, Joe!</h1>"
}
```
## Development
```sh
gleam build # Build the project
gleam test # Run the tests
gleam test tabs # Run only the Tabs section of tests
gleam test tabs 9 # Run only example number 9 from the test section
gleam test custom # Run only extra tests (not from the spec)
```
## Requirements (Erlang)
- Gleam 1.13+
- Erlang 28+ (due to PCRE2 usage)
## Requirements (Javascript)
- Gleam 1.13+
## Data sources
- `gen/emoji.json`: \
<https://raw.githubusercontent.com/iamcal/emoji-data/master/emoji.json>
- `gen/entities.json`: \
<https://html.spec.whatwg.org/entities.json>
[^footnotes]: <https://www.markdownguide.org/extended-syntax/#footnotes>