You can explicitly convert a plain text document to a document object by passing it to the document
function.
If hokusai.md
contains plain text:
$ ori hokusai.md
I write, erase, rewrite
Erase again, and then
A poppy blooms.
then invoking document
on it returns a plain object with the original body text as a text
property:
$ ori document hokusai.md
"@text": |
I write, erase, rewrite
Erase again, and then
A poppy blooms.
You can also attach data:
$ ori document hokusai.md, { author: "'Katsushika Hokusai'" }
author: Katsushika Hokusai
"@text": |
I write, erase, rewrite
Erase again, and then
A poppy blooms.
If you have a text document with data in front matter:
$ ori basho.md
---
author: Basho
---
No one travels
Along this way but I,
This autumn evening.
Then calling document
on it returns a plain object with the front matter data as properties, plus the body text as a text
property:
$ ori document basho.md
author: Basho
"@text": |
No one travels
Along this way but I,
This autumn evening.
If you have a collection of documents, some of which have data and some of which don’t, you can normalize all of them to document objects by applying document
to each of them.
$ ori map [basho.md, hokusai.md], =document _
- author: Basho
"@text": |
No one travels
Along this way but I,
This autumn evening.
- "@text": |
I write, erase, rewrite
Erase again, and then
A poppy blooms.
All of the objects in the result are now document objects with a text
property.