retext-dom
Create a DOM tree from a retext document.
Note: retext-dom only works in the browser (d’oh), or with a Node.js DOM such as jsdom.
Installation
npm:
npm install retext-dom
retext-dom is also available for bower, component, and duo, and as an AMD, CommonJS, and globals module, uncompressed and compressed.
Usage
var retext = ;var dom = ;var processor = ; processor;
Yields (Note: White-space between nodes added for readability, this is not actually inserted!):
A simple English sentence .
API
retext.use(dom[, options])
Instead of compiling to text, generate a DOM-node.
Parameters:
-
dom
— This module; -
options
(Object
, optional):-
tags
(Object
, optional) — Object of nlcst types mapping to HTML tags. The initial values look as follows:'WhiteSpaceNode': 'span''PunctuationNode': 'span''SymbolNode': 'span''ParagraphNode': 'p''RootNode': 'div'When omitted, the default is a
#text
for nodes with a value, and aspan
for all others.
-
Integrations
All nlcst nodes can be re-created as
DOM-nodes. In addition, retext-dom looks for an attributes
object on each
node it compiles and adds the found properties as HTML attributes on the
generated DOM node.