eno » parse

parse(input) → Section
parse(input, options) → Section

Parse a string in eno notation.

enocolor: blue
javascriptconst eno = require('enojs');
const { HtmlReporter, TerminalReporter} = require('enojs');  // if you want to use something else than the default TextReporter

eno.parse(input);  // returns [object Section document elements=1]

                                                   // Errors will be ...
eno.parse(input, { locale: 'es' });                // In spanish - ¡hola!
eno.parse(input, { reporter: HtmlReporter });      // HTML for e.g. web integration
eno.parse(input, { reporter: TerminalReporter });  // Colored for terminal output
eno.parse(input, { sourceLabel: 'my-file.eno' });  // Annotated with a label as context
eno.parse(input, { zeroIndexing: true });          // Counting line and column numbers from 0

Parameters

input

A string containing text in eno notation.

options

locale

A string specifying the code of the locale to use for error messages (e.g. 'de', 'es'), by default 'en'.

reporter

One of TextReporter (default), HtmlReporter, TerminalReporter, all three available as named exports from require('enojs').

source_label

A string that labels where the input comes from (e.g. a filename), this is included with error messages to help the user located the file.

zeroIndexing

true or false (default), set true to display 0,1,2,.. line and column numbers in all error messages instead of the default 1,2,3,.. indexing.

Return value

An Section representing the document.