@frantic1048/est
v0.0.4
Published
reStructuredText parser and renderer
Maintainers
Readme
Est
|license|_ |code quality|_ |ci|_ |dm|_
.. |license| image:: https://img.shields.io/github/license/frantic1048/est.svg?style=flat-square
.. _license: https://github.com/frantic1048/est/blob/master/LICENSE
.. |code quality| image:: https://img.shields.io/codacy/grade/3aa60448106f4001b7ac194829f98397.svg?style=flat-square
.. _code quality: https://www.codacy.com/app/frantic1048/Est/dashboard
.. |ci| image:: https://img.shields.io/travis/frantic1048/Est.svg?style=flat-square
.. _ci: https://travis-ci.org/frantic1048/Est
.. |dm| image:: https://img.shields.io/david/frantic1048/Est.svg?style=flat-square
.. _dm: https://david-dm.org/frantic1048/Est
reStructuredText parser and renderer.
Install
Use yarn to fetch the package, or npm if you prefer.
.. code:: sh
yarn add @frantic1048/EstUsage
After build:
.. code:: js
// 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 .
.. _ASTy: https://github.com/rse/asty
The node structure of a specific markup could be referred in test/grammar.<MarkupName>.js
Render function is under constructing.
Build
Prepare:
.. code:: sh
# fetch source code
git clone https://github.com/frantic1048/Est.git
# fetch dependencies
yarnBuild and run test:
.. code:: sh
yarn ciProduction build:
.. code:: sh
yarn distDevelop:
.. code:: sh
yarn devThe 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.
Recognized Markups
:Inline:
emphasis <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#emphasis>_strong emphasis <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#strong-emphasis>_interpreted text <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#interpreted-text>_inline literal <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-literals>_hyperlink reference <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-references>_substitution reference <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-references>_inline internal target <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-internal-targets>_standalone hyperlink <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#standalone-hyperlinks>_URI is refer to
RFC 3986 <https://tools.ietf.org/html/rfc3986#appendix-A>_ 'sabsolute-URIdefinition, no scheme restriction.Email address is a simplified subset of URI. See
TextEmailAdressrule insrc/parser.pegjs
:Block-level:
section <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#sections>_Unlike adorment line should be longer than title text in spec, section adornment length > 3 is accepted length.
transition <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#transitions>_paragraph <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#paragraphs>_bullet list <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#bullet-lists>_fixed 2 spaces indent.
enumerated list <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#enumerated-lists>_the text immediately after the enumerator determines the indentation (same as spec).
definition list <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#definition-lists>_fixed 4 spaces indent.
field list <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#field-lists>_option list <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#option-lists>_footnote <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#footnotes>_standalone hyperlink is not recognized in field name, while the other inline markups is recognized.
citation <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#citations>_hyperlink target <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets>_directive <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#directives>_substitution definition <http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#substitution-definitions>_
