Tutorial: make an analysis notebook cute¶
This tutorial starts with a normal notebook named analysis.ipynb and creates
a styled copy. Your original is left untouched.
1. Install cutiepynb¶
1 | |
Check that the command is available:
1 | |
2. Try the default palette¶
1 | |
Open analysis_chulo.ipynb. You should see:
- A table of contents in the first cell.
- Colored Markdown headings.
- Links that jump to the corresponding sections.
The command refuses to overwrite analysis_chulo.ipynb by default. This makes
experimentation safe. Add --force when replacing that file is intentional:
1 | |
3. Choose your own colors¶
Repeat --color to build a palette. The first color is used for # headings,
the second for ##, and so on. If there are more heading levels than colors,
the palette repeats.
1 2 3 4 5 | |
CSS color names also work:
1 | |
4. Use it from Python¶
The recommended file API returns the path it wrote:
1 2 3 4 5 6 7 8 9 10 | |
Existing output is protected. To replace it explicitly:
1 2 3 4 5 6 | |
5. Use a seaborn palette¶
Seaborn support is optional, so it does not make the base installation heavy.
1 2 | |
The same option is available in Python:
1 2 3 | |
6. Transform a notebook already loaded in memory¶
Use create_new_document when another tool has already loaded the notebook.
The input dictionary is not changed.
1 2 3 4 5 6 7 8 9 10 11 | |
You can then pass styled to the next step of your own application.
The in-memory API can also correct headings while it styles the notebook. The indices are zero-based and follow Markdown headings in document order:
1 2 3 4 5 6 7 8 | |
Headings in code cells, fenced examples, and generated tables of contents do not count toward those indices.
7. Update an existing palette¶
If a notebook dictionary already contains styled cutiepynb headings, update the colors without nesting new HTML spans:
1 2 3 4 5 6 | |
Both functions return a new dictionary and keep their input unchanged.
Calling create_new_document again with a different palette is also safe: it
rebuilds cutiepynb's spans, anchors, and table of contents instead of stacking
new markup on top of the old output.
8. Optional behaviors¶
Skip the table of contents:
1 | |
Replace the input only when you really want to:
1 | |
For reproducible analysis projects, creating a separate output is usually the better choice. Generated notebooks can be rebuilt from their originals.
What counts as a heading?¶
cutiepynb recognizes standard ATX Markdown headings:
1 2 3 | |
Headings inside code cells or fenced examples are ignored. Duplicate heading
names receive unique anchors such as results and results-2.
Next, see the command and API reference.