unified-doc

Overview

Recipes for best ways to use the API methods exposed by a doc instance.

doc.compile()

Use this method if you want to compile and render the document as in this example of compiling to react:

Live Code Editor
Preview
Render the doc anywhere in the React tree

some markdown content

doc.file()

Use this method if you want to create or work with the corresponding JS File, filename, extensions, and mime type. This method is also useful for exporting to other supported formats.

Live Code Editor
Preview
Check console for logged file

doc.parse()

Use this method if you want to obtain the hast representation of the content, which is useful if you want to work with the syntax tree directly (e.g. with hast utils).

Live Code Editor
Preview
Check console for logged content

doc.search()

Use this method if you want to search for matches for in the document for a given query and attached search algorithm. Search results are simple and conveniently return start/end offset and snippet information that is useful to display context around the matched search value.

This method is useful when returning interface-compatible data for marks to highlight matches in a document. It is also useful in general for computing offsets and derived data in other NLP pipelines and processes.

Live Code Editor
Preview

Compiled

some markdown content, content, content

Results

some markdown content, content, content (start: 15, end: 22)
some markdown content, content, content (start: 24, end: 31)
some markdown content, content, content (start: 33, end: 40)

doc.textContent()

Use this method if you want to obtain the textContent representation of the document, useful for computing offsets and derived data in other NLP pipelines and processes.

Live Code Editor
Preview
Text content: some markdown content, content, content
Term: content
Count: 3
© 2020 unified-doc