comment parser with support for markdown, positional info, and concrete tokens.
- What is this?
- When should I use this?
- Install
- Use
- API
- Extensions
- Architecture
- Examples
- Docdown
- Project
docmark is an open source comment parser with support for markdown written in TypeScript.
The parser is implemented as a state machine that emits concrete tokens with positional info.
External tools and libraries can turn these tokens into different things.
TODO: when should i use this?
This package is ESM only.
In Node.js (version 22+) with yarn:
yarn add @flex-development/docmarkSee Git - Protocols | Yarn for details regarding installing from Git.
In Deno with esm.sh:
import { parse, postprocess, preprocess } from 'https://esm.sh/@flex-development/docmark'In browsers with esm.sh:
<script type="module">
import { parse, postprocess, preprocess } from 'https://esm.sh/@flex-development/docmark'
</script>TODO: use
See § API in the docmark readme.
docmark supports extensions.
Extensions change how comments are parsed.
A syntax extension is an object whose fields are typically the names of hooks, referring to where constructs "hook" into. The fields at such objects are character codes, mapping to constructs as values, while other fields provide parser configuration or additional behavior.
The builtin extensions are an example.
See them and existing extensions for inspiration.
@flex-development/docmark-extension-hashbang— support hasbang comment syntax@flex-development/docmark-extension-js— support javascript comment syntax@flex-development/docmark-extension-jsonc— support json comment syntax@flex-development/docmark-extension-sass— support sass comment syntax@flex-development/docmark-extension-shell— support shell comment syntax@flex-development/docmark-extension-ts— support typescript comment syntax@flex-development/docmark-extension-yaml— support yaml comment syntax
TODO: extending docdown
TODO: creating a docmark extension
TODO: overview
TODO: preprocess
TODO: parse
TODO: postprocess
TODO: directives
TODO: github flavored markdown (gfm)
TODO: math
TODO: syntax tree
TODO: commonmark
TODO: grammar
docmark adheres to semver.
See CONTRIBUTING.md.
This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.
Consider sponsoring to support maintenance, tests, and long-term stability!
TODO: origin