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 _body
property:
$ ori Origami.document hokusai.md
_body: |
I write, erase, rewrite
Erase again, and then
A poppy blooms.
You can also attach data:
$ ori Origami.document hokusai.md, { author: "'Katsushika Hokusai'" }
author: Katsushika Hokusai
_body: |
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 _body
property:
$ ori Origami.document basho.md
author: Basho
_body: |
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 Tree.map [basho.md, hokusai.md], =Origami.document _
- author: Basho
_body: |
No one travels
Along this way but I,
This autumn evening.
- _body: |
I write, erase, rewrite
Erase again, and then
A poppy blooms.
All of the objects in the result are now document objects with a _body
property.