Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mscharley/gleam-commonmark
CommonMark implementation for Gleam
https://github.com/mscharley/gleam-commonmark
Last synced: about 1 month ago
JSON representation
CommonMark implementation for Gleam
- Host: GitHub
- URL: https://github.com/mscharley/gleam-commonmark
- Owner: mscharley
- License: mit
- Created: 2024-05-28T14:56:44.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-05-29T00:39:59.000Z (7 months ago)
- Last Synced: 2024-05-29T08:18:27.074Z (7 months ago)
- Language: Gleam
- Size: 28.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-gleam - commonmark - [📚](https://hexdocs.pm/commonmark/) - CommonMark implementation for Gleam, for the BEAM or JS (Packages / Formats)
README
# commonmark
[![Package Version](https://img.shields.io/hexpm/v/commonmark)](https://hex.pm/packages/commonmark)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/commonmark/)
![Erlang-compatible](https://img.shields.io/badge/target-erlang-b83998)
![JavaScript-compatible](https://img.shields.io/badge/target-javascript-f1e05a)```sh
gleam add commonmark
```
```gleam
import commonmark/html as commonmark
import gleam/iopub fn main() {
"# Hello, Gleam!This is a test."
|> commonmark.render_to_html
|> io.println
// -> "Hello, Gleam!
\nThis is a test.
\n"
}
```Further documentation can be found at .
[You can view this README as an AST here.][readme-ast]
There is also an [interactive demo][demo] which you can use to test how this library interacts with your documents.
[readme-ast]: https://github.com/mscharley/gleam-commonmark/tree/main/birdie_snapshots/common_mark_readme.accepted
[demo]: https://mscharley.github.io/gleam-commonmark/## Syntax support
> [!WARNING]
> 🚧 This package is still heavily under construction 🚧### Legend
* ✅ - Completed
* 🚧 - In Progress
* ❌ - Unsupported### CommonMark
The current version of CommonMark targetted is [0.31.2][commonmark].
* ✅ Thematic breaks
* ✅ ATX headings
* ✅ Setext headings
* ✅ Indented code blocks
* ✅ Fenced code blocks
* ❌ Link reference definitions
* ✅ Paragraphs
* ✅ Block quotes
* 🚧 Ordered lists
* 🚧 Unordered lists
* ✅ Code spans
* 🚧 Emphasis and strong emphasis
* 🚧 Links
* 🚧 Images
* ✅ Autolinks
* ✅ Hard line breaks
* ✅ Soft line breaksRaw HTML features will be tackled last as the potential security issues around this need to be considered.
* ❌ HTML blocks
* ❌ Inline HTML[commonmark]: https://spec.commonmark.org/0.31.2/
### Github Flavoured Markdown
The current version of GFM targetted is [0.29-gfm][gfm].
* ❌ Tables
* ✅ Strikethrough[gfm]: https://github.github.com/gfm/
### Other extensions
* ✅ [Github alerts][github-alert]
[github-alert]: https://github.com/orgs/community/discussions/16925
## Project structure
The `commonmark` package is just the parser as well as a simple HTML renderer which
returns a string, mostly to facilitate checking CommonMark spec compliance. Most
likely you want a specialised render for whatever framework you're using though.Known renderer projects:
* `commonmark/commonmark` is a CommonMark renderer, useful if you want to generate
an AST and write out a document based on it.
* `commonmark/html` is a HTML renderer included as part of this package.## Development
```sh
gleam test # Run the tests
gleam shell # Run an Erlang shell
```### Tools
```sh
cd tools/
gleam run -m benchmark # Run the benchmarks
gleam run -m codegen # Run the codegen tasks (these are committed in the repo)
```