Crates.io | dmos |
lib.rs | dmos |
version | 0.3.0 |
source | src |
created_at | 2024-04-11 20:19:15.520832 |
updated_at | 2024-04-15 14:30:28.638027 |
description | Djot HTML renderer with advanced features |
homepage | https://sr.ht/~bitfehler/dmos |
repository | https://git.sr.ht/~bitfehler/dmos |
max_upload_size | |
id | 1205399 |
size | 27,363 |
DMOS is a Djot HTML renderer with some advanced features. Parsing and rendering basics are handled by jotdown. DMOS adds the following features:
DMOS will automatically attempt to add CSS-class-based syntax highlighting to all fenced code blocks with a language specifier. The default highlighter is syntect, which means it is small and fast, but also line-based (which is not an issue for the vast majority of code snippets).
For the adventurous, an alternative highlighter based on inkjet/tree-sitter is also available. Tree-sitter is quite sophisticated, but the executable size will be huge (see their README).
DMOS can generate a table of contents for a document. The table's prologue
and epilogue are customizable, meaning it can be embedded into the document
with arbitrary elements (<section>
, <div>
, <details>
, ...).
There is also an option to exclude the document title from the table of contents. If enabled, DMOS will also emit the table of contents after the title (providing a more natural document structure: title, TOC, content).
DMOS can add section anchors to headings linking to themselves. These anchors are a common technique to allow readers to easily get the link to a specific section. They are usually styled with CSS to only appear when hovering over the heading. If you are viewing the HTML rendering of this document on sr.ht you can see a similar mechanism in action by hovering the mouse over any section heading.
The dmos crate is a library, dmos-cli is a thin CLI wrapper around it.
For usage of the library, see the crate documentation.
For usage of the CLI:
Usage: dmos [OPTIONS] [FILE]
Arguments:
[FILE] Read input from FILE instead of stdin
Options:
-a, --anchor <ANCHOR> Add anchors with text ANCHOR to headings
-t, --title-only Output first first-level heading and exit
--toc Generate document with table of contents
-T, --toc-only Output table of contents and exit
--toc-skip-title Skip title (first heading) in table of contents
--toc-prologue <HTML> Prologue to the table of content listing [default: "<section class=\"toc\"><h3>Table of Contents</h3>"]
--toc-epilogue <HTML> Epilogue to the table of content listing [default: </section>]
-h, --help Print help
-V, --version Print version
Feel free to send questions, patches, or other feedback to my public inbox.