https://github.com/kivikakk/koino
CommonMark + GFM compatible Markdown parser and renderer
https://github.com/kivikakk/koino
commonmark markdown zig
Last synced: 14 days ago
JSON representation
CommonMark + GFM compatible Markdown parser and renderer
- Host: GitHub
- URL: https://github.com/kivikakk/koino
- Owner: kivikakk
- License: mit
- Created: 2020-08-12T07:24:47.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-07-01T23:10:59.000Z (over 1 year ago)
- Last Synced: 2025-01-13T05:03:25.877Z (9 months ago)
- Topics: commonmark, markdown, zig
- Language: Zig
- Homepage: https://hrzn.ee/kivikakk/koino
- Size: 223 KB
- Stars: 132
- Watchers: 6
- Forks: 13
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
- awesome-zig - kivikakk/koino
- awesome-zig - koino🗒️CommonMark + GFM compatible Markdown parser and renderer
README
# koino

Zig port of [Comrak](https://github.com/kivikakk/comrak). Maintains 100% spec-compatibility with [GitHub Flavored Markdown](https://github.github.com/gfm/).
## Getting started
### Using koino as a library
* Add koino via the zig package manager:
```console
$ zig fetch --save git+https://nossa.ee/~talya/koino
```
* Add the following to your `build.zig`'s `build` function:
```zig
const koino_pkg = b.dependency("koino", .{ .optimize = optimize, .target = target });
exe.root_module.addImport("koino", koino_pkg.module("koino"));
```* Have a look at the bottom of [`parser.zig`](src/parser.zig) to see some test usage.
### Using it as a CLI executable
* Clone this repository:
```console
$ git clone https://nossa.ee/~talya/koino
```
* Build
```console
$ zig build
```
* Use `./zig-out/bin/koino`### Development
There's a `flake.nix` for building or getting a devShell if you're so-inclined.
* Clone this repository (with submodules for the `cmark-gfm` dependency):
```console
$ git clone --recurse-submodules https://nossa.ee/~talya/koino
$ cd koino
```* Build and run the spec suite.
```console
$ zig build test
$ make spec
```## Usage
Command line:
```console
$ koino --help
Usage: koino [-hu] [-e ...] [--header-anchors] [--smart]Options:
-h, --help
Display this help and exit-u, --unsafe
Render raw HTML and dangerous URLs-e, --extension ...
Enable an extension (table,strikethrough,autolink,tagfilter)--header-anchors
Generate anchors for headers--smart
Use smart punctuation
```Library:
Documentation is TODO — see [LoLa](https://github.com/MasterQ32/LoLa/blob/d02b0e6774fedbe07276d8af51e1a305cc58fb34/src/tools/render-md-page.zig#L157) for an example of use. Note also the [`build.zig`](https://github.com/MasterQ32/LoLa/blob/d02b0e6774fedbe07276d8af51e1a305cc58fb34/build.zig#L41-L50) declaration.