(define sixhat (λ (dave) (display 'ideas)))

Writing slides structure from the Topics slide in marp

I use marp to produce most of my slides and found it very interesting to layout the structure of the presentation in the Agenda/Topics slide. This slide acts as an organizer for the presentation.

I might write something like

## Topics

- Talk about awk
- Explain why Julia rocks
  - Show examples

But then I have to create the slides, and the following snippet of shell code allows me to get the code for the slides in my presentation. It takes the file.md and parses the lines starting with '- ' and produces the outline like

---

## Talk about awk

---

## Explain why Julia rocks

---

### Show examples

This is all accomplished with old faithful awk.

function mdIndex {
  awk '/^- / {$1="";print "\n---\n\n##"$0 } / +- /{$1="";print "\n---\n\n###"$0}' $1
}

Just put it in .zprofile and you can run it like this and get the results in the terminal,

$ mdIndex file.md

or you can pipe it to pbcopy and then paste the output into your editor of choice.

$ mdIndex file.md | pbcopy