= NBProcessor(_test_file, procs=FrontmatterProc)
nbp
nbp.process()print(nbp.nb.cells[0].source)
---
categories:
- c1
- c2
description: A description
execute:
echo: false
key1: value1
key2: value2
output-file: docs_test.html
title: a title
---
FrontmatterProc (nb)
A YAML and formatted-markdown frontmatter processor
YAML frontmatter can be added to notebooks in one of two ways:
---
as the first and last lines, and YAML between them, or#
(creating an H1 heading), and becomes the title. Then, optionally, a line beginning with >
(creating a quote block), which becomes the description. Finally, zero or more lines beginning with -
(creating a list), each of which contains YAML. (If you already have “title” defined in frontmatter in a raw cell, then markdown cells will be ignored.)For instance, our test notebook contains the following markdown cell:
# a title
> A description
- key1: value1
- key2: value2
- categories: [c1, c2]
It also contains the following raw cell:
---
execute:
echo: false
---
When we process with FrontmatterProc
, these will both be removed, and a single raw cell will be added to the top, containing the combined YAML frontmatter:
---
categories:
- c1
- c2
description: A description
execute:
echo: false
key1: value1
key2: value2
output-file: docs_test.html
title: a title
---
In addition, a frontmatter_
attr will be added to the notebook, containing this information as a dict
: