DunneNote · Tutorial
Create a notebook from a script
Build a DunneNote notebook from Markdown files and pictures with dnfmt, then open it in DunneNote.
In this tutorial you'll use dnfmt, the open-source command-line tool for
DunneNote notebooks, to turn a folder of Markdown notes and a picture into a
notebook, then open it in DunneNote. It's a good way to bring notes in from
another tool, or to generate a notebook from a script.
You'll need#
dnfmton your path, and DunneNote 0.9.- A few Markdown files, for example
day1.mdandday2.md, and a picture such asmap.png. - A terminal, opened in the folder that holds them.
Create the notebook#
- Run
dnfmt new Trip.dunnenote --name="Summer Trip". This makes a new notebook folder. The name is what DunneNote shows in its sidebar. - Run
dnfmt add-section Trip.dunnenote root "Days". It prints the new section's id. Keep it for the next step; in a shell script, save it withSECTION=$(dnfmt add-section …). - Run
dnfmt add-page Trip.dunnenotefollowed by the section id and"Day 1". It prints the page's id. The page starts with the same empty text box that DunneNote gives a new page.
Add your notes#
- Run
dnfmt add-canvas Trip.dunnenotefollowed by the page id,rich-textandday1.md. Headings, paragraphs, lists, bold, italic, strike and links come across as formatted text. - Run the same command with
picture map.png --alt="Route map"in place ofrich-text day1.md. The picture is placed below the text, at its own size. - Repeat for
Day 2withday2.md.
If a command can't add something exactly as DunneNote would show it, for example a file that isn't a picture DunneNote supports, it changes nothing and tells you why.
Check it and open it#
- Run
dnfmt verify Trip.dunnenote --full --strict. It ends withok, and notes that the search index is empty. - Open
Trip.dunnenotein DunneNote. Your sections, pages, text and picture are there. DunneNote builds the search index as it opens the notebook, so search works straight away.
A whole folder at once#
Because each command prints an id, a short shell loop can add one page per Markdown file:
NB=Trip.dunnenote
SECTION=$(dnfmt add-section $NB root "Days")
for f in day*.md; do
PAGE=$(dnfmt add-page $NB $SECTION "${f%.md}" --no-text)
dnfmt add-canvas $NB $PAGE rich-text "$f"
done
--no-text leaves out the empty text box, since each page gets its own text
straight away.
Before you edit an existing notebook#
dnfmt can also add to a notebook you already use. Close it in DunneNote first:
dnfmt refuses a notebook that DunneNote has open. Keep a backup, as you would
with any tool that changes your files. See Backup and restore.
Next#
Something unclear or out of date? Open a support ticket.