app

Mapper for server env, mapping strings or jsdom objects.

Maps HTML for next-book use.

map(content: (Array<string> | Array<JSDOM>), filenames: array, options: config~Options, revision: string): array
Parameters
content ((Array<string> | Array<JSDOM>)) Array of jsdom objects or strings
filenames (array) Names of files from which content was read
options (config~Options) The options
revision (string) Revision identifier string
Returns
array: Array of mapped documents in specified format

browser

Mapper for browser env, mapping DOM contents. Accessible at window.NbMapper.

browser
Static Members
mapHtml(options)

config

Set of config options. See default values in defaults.

Options

Type: Object

Properties
output (("jsdom" | "html")) : Output format (jsdom object or HTML strings).
delimiter ((string | RegExp | tokenizerFn)) : Delimiter used to split chunks into ideas or a callback used to split chunks into ideas.
restoreDelimiter ((bool)) : Determines whether to append delimiter after each idea when assembling. Cannot be used when delimiter is a RegExp.
selectors ((array | selectorFn)) : Array of selectors of mappable chunks of a document or a callback that marks chunks.

Merges defaults with provided overrides.

load
Parameters
options (Object) Config overrides
Returns
Object: Complete configuration

tagger

Tagger parses, produces and numbers chunks and ideas.

tagDocument

src/tagger.js

Recognizes and tags chunks and ideas in a document

tagDocument(document: Object, options: Options): void
Parameters
document (Object) DOM document
options (Options) Config
Returns
void: Modifies DOM document

selectorFn

src/tagger.js

Callback that marks elements as chunks of ideas. Those are then used for idea mapping.

selectorFn(document: Object): void

Type: Function

Parameters
document (Object) DOM document
Returns
void: Modifies DOM document

tokenizerFn

src/tagger.js

Callback used to split chunk contents into ideas.

tokenizerFn(node: Object, text: string): Array<string>

Type: Function

Parameters
node (Object) DOM node
text (string) Text content.
Returns
Array<string>: Text split into 1-n parts (string, Node or ParsedObj) used for idea construction.

parser

Parser produces instances of ParsedObj from Element contents.

Returns ParsedObj which contains original node and an array of arrays in which every array represents one idea or ParsedObj. Ideas are delimited with a delimiter that is searched for in text nodes.

parse(node: Node, delimiter: (string | RegExp | tokenizerFn)): ParsedObj
Parameters
node (Node) DOM node
delimiter ((string | RegExp | tokenizerFn)) The delimiter
Returns
ParsedObj: An instance of ParsedObj

producer

Producer assembles ideas back into HTML where ideas are represented with annotated span elements.

Produces ideas from a parsedObj

produce(document: Object, parsedObj: ParsedObj): Node
Parameters
document (Object) DOM document
parsedObj (ParsedObj) A parsed object
Returns
Node: HTML node

gauge

Gauge counts words and characters in a document and sums those in a publication.

gaugeDocument

src/gauge.js

Gauges words and characters in a document.

gaugeDocument(document: Object): void
Parameters
document (Object) DOM document
Returns
void: Modifies DOM document

gaugePublication

src/gauge.js

Gauges words and characters in a publication. Relies on previous gauging of individual chunks using gaugeDocument.

gaugePublication(documents: Array<Object>): void
Parameters
documents (Array<Object>) DOM documents
Returns
void: Modifies DOM documents

structures

Data structures used in the other parts.

ParsedObj contains original node and an array in which every item is an array of strings and HTML elements, a full-whitespace string or another ParsedObj.

new ParsedObj(node: window.Node, ideas: Ideas, delimiter: string)
Parameters
node (window.Node) DOM node
ideas (Ideas) Ideas object
delimiter (string) Delimiter
Example
{
 node: <p class="chunk">,
 ideas: [
   ["Integer nec odio."],
   " ",
   ["Praesent ", <strong>, ", nibh elementum imperdiet."],
   " ",
   ["Sed cursus ante dapibus diam."],
   " ",
   [ParsedObj],
   " ",
   …
 ]
}

A note about these docs

See project's README.

With current versions of JSDoc, ESDoc and documentation.js it is hard to work
with ES6 modules that do not use classes internally. Any tips for tools that do not require hacks are welcome!

Ideas contains an array of items in which every item is an array of strings and HTML elements, a whitespace-only string or a ParsedObj.

new Ideas(node: window.Node, ideas: Ideas, delimiter: string)
Parameters
node (window.Node) DOM node
ideas (Ideas) Ideas object
delimiter (string) Delimiter
Example
{
 arr: [
   ["Integer nec odio."],
   " ",
   ["Praesent ", <strong>, ", nibh elementum imperdiet."],
   " ",
   ["Sed cursus ante dapibus diam."],
   " ",
   [ParsedObj],
   " ",
   …
 ]
}