Created
May 6, 2021 10:01 AM
Description
Splits one Markdown file Into multiple by heading
Last Edited
Jan 27, 2022 06:36 AM
Tags
Automation
Code
Split by H1 (#)
csplit --prefix='note' --suffix-format='%02d.md' --elide-empty-files notes.md '/^#\s.*/' '{*}'
Use Pandoc
to shift headings by one level
find ./ -iname "*.md" -type f -exec sh -c 'pandoc --shift-heading-level-by=-1 --wrap=preserve "${0}" -o "${0}"' {} \;
Parameters
--prefix
'/^#\s.*/'
prefix for output file name
Matches H1