Chunk

Type: Class

Represents a single 'chunk' of incompletely annotated text

Constructor

# Name Type Description
1. text String

The type of text the chunk represents

Properties

Name Type Description
text String

The text content of this chunk. Mutate it in an input processor.

Methods

Name Description
addFallback

Set the fallBackfunction, used when converting back from the annotated text for a plain text import Add a fallbackFunction undoing every text change done. ie: originalText = '- A list item'

// Execute a text change text = 'A list item' // Remove the '- ' addFallback(function (chunk){ chunk.text = '- ' + chunk.text}); // Make it be added back when falling back to plain text


  Arguments
# Name Type Description
1. fallbackFunction Function

A function which will be passed a string, and should return a string undoing any textChanges

addLabel

Add a label for this chunk


  Arguments
# Name Type Description
1. label String

The type of label the chunk should have, for instance, Paragraph of List

2. [metadata] Object

The metadata for the Chunk, for instance, the approximated indentation level for the chunk

fallback

Fallback to the original version of the text, used for falling back to a plain text import


  Returns

Type: String

An approximation of the original text