reStructuredText parser and renderer.
Use yarn to fetch the package, or npm if you prefer.
yarn add @frantic1048/Est
After build:
// do not forget the ``@frantic1048`` scope
import est from '@frantic1048/Est'
// directly render rST into HTML string
const html = est.rst2html('reStructuredText string...')
// or...?
// welcome to the dark side...
// generate parsing tree
// which is an ASTy instance
const parse_t = est.parse('reStructuredText string...')
// transfrom parsing tree into doc tree
// which is an ASTy instance
const doc_t = est.transfrom(parse_t)
// render the doc tree into HTML string
const html_the_harder_way = est.render(doc_t)
All node types of the parsed tree can be found from est.TokenTypes
.
The node structure of a specific markup could be referred in test/grammar.<MarkupName>.js
Render function is under constructing.
Prepare:
# fetch source code
git clone https://github.com/frantic1048/Est.git
# fetch dependencies
yarn
Build and run test:
yarn ci
Production build:
yarn dist
Develop:
yarn dev
The build output is under lib
folder. All possible files are:
- est.dev.js
trace on, CommonJS module, debug and develop oriented.
- est.min.js
trace off, single variable, Browser oriented.
- est.js
trace off, CommonJS module, Node.js oriented.
- Inline
- emphasis
- strong emphasis
- interpreted text
- inline literal
- hyperlink reference
- substitution reference
- inline internal target
URI is refer to RFC 3986 's
absolute-URI
definition, no scheme restriction.Email address is a simplified subset of URI. See
TextEmailAdress
rule insrc/parser.pegjs
- Block-level
Unlike adorment line should be longer than title text in spec, section adornment length > 3 is accepted length.
- transition
- paragraph
fixed 2 spaces indent.
the text immediately after the enumerator determines the indentation (same as spec).
fixed 4 spaces indent.
- field list
- option list
standalone hyperlink is not recognized in field name, while the other inline markups is recognized.
- citation
- hyperlink target
- directive
- substitution definition