@flex-development/docmark
v1.0.0-alpha.24
Published
commonmark compliant documentation parser with positional info and concrete tokens
Maintainers
Readme
docmark
a comment parser with support for markdown.
Note: This is the
docmarkpackage from the docmark monorepo.
See the monorepo readme for more on the project.
See this readme for how to use it.
Contents
What is this?
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.
When should I use this?
TODO: when should i use this?
Install
This package is ESM only.
In Node.js (version 22+) with yarn:
yarn add @flex-development/docmarkIn Deno with esm.sh:
import { docmark } from 'https://esm.sh/@flex-development/docmark'In browsers with esm.sh:
<script type="module">
import { docmark } from 'https://esm.sh/@flex-development/docmark'
</script>Use
TODO: use
API
This package exports the identifiers docmark, parse, postprocess,
and preprocess.
The default export is docmark.
docmark(value[, encoding][, options])
Create an event stream.
Overloads
function docmark(
this: void,
value: FileLike | Value | null | undefined,
encoding?: Encoding | null | undefined,
options?: Options | null | undefined
): Event[]function docmark(
this: void,
value: FileLike | Value | null | undefined,
options?: Options | null | undefined
): Event[]Parameters
value(FileLike|Value|null|undefined) — the source file or content to parseencoding(Encoding|null|undefined, optional) — the character encoding to use whenvalueor its contents is anUint8Arrayoptions(Options|null|undefined, optional) — the configuration options
Returns
(Event[]) The list of events
parse([options])
Create a parser.
Tokenizers deal with one content type.
The parser is the object dealing with it all.
Parameters
options(ParseOptions|null|undefined, optional) — the parse options
Returns
(ParseContext) The parse context
postprocess(events)
Postprocess events.
Parameters
events(Event[]) — the current list of events
Returns
(Event[]) The list of changed events
preprocess([options])
Create a preprocessor to turn a value into chunks.
Parameters
options(PreprocessOptions|null|undefined, optional) — the configuration options
Returns
(Preprocessor) The preprocessor
Types
This package is fully typed with TypeScript.
It exports additional types.
Options
Extends
Properties
contentType(ContentType|null|undefined, optional) — the content type of the parser to run- default:
constants.contentTypeComments
- default:
from(Point|null|undefined, optional) — the point before the first character in the content.
token positions will be relative to this point- default:
{ column: 1, line: 1, offset: 0 }
- default:
Contribute
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.
