Here is another potentially useful Keyboard Maestro macro. This time for creating a TOC from headings within the text. You have to be in editor mode, with the cursor in the text. Once triggered, it will select all the text, copy it, parse it and return a structured TOC in a display window and to the clipboard.
Example:
# Markdown
#LoremIpsum
[[Lorem Ipsum]]
# H1
## H2
### H3
#### H4
##### H5
###### H6
##### H5
#### H4
### H3
## H2
# H1
The macro will return:
## Content
- [[#Markdown]]
- [[#H1]]
- [[#H2]]
- [[#H3]]
- [[#H4]]
- [[#H5]]
- [[#H6]]
- [[#H5]]
- [[#H4]]
- [[#H3]]
- [[#H2]]
- [[#H1]]
[[#Content]]
MacOS only.