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
:
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.
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).
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.
some markdown content, content, content
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.
some markdown content, content, content
content
3