Created
October 7, 2021 16:55
-
-
Save stefan2904/b74b6141d3ebe89beaf095e62320f0b4 to your computer and use it in GitHub Desktop.
Convert directory of markdown files into orgmode heading
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# if [[ -d $PASSED ]]; then | |
# echo "$PASSED is a directory. Let's convert it." | |
# elif [[ -f $PASSED ]]; then | |
# echo "$PASSED is a file. Try md2org instead?" | |
# exit 2 | |
# else | |
# echo "$PASSED is not valid?" | |
# exit 1 | |
# fi | |
cd $1 | |
for f in *.md; do | |
echo "" | |
filename="${f%%.*}" | |
echo "** $filename" | sed 's/_/ /' | |
pandoc --from markdown --to org "$f" \ | |
| sed 's/\[toc\]//' \ | |
| sed 's/\.\.\/\.\.\/_resources/file:\.\.\/_resources/' \ | |
| sed 's/\.\.\/\.\.\/work/\.\.\/work/' \ | |
| sed 's/\.\.\/journals/\.\.\/work\/journals/' \ | |
| sed 's/^\* /*** /' \ | |
| sed 's/^\*\* /*** /' \ | |
| sed 's/ :/:/' \ | |
| sed 's/☒/\[x\]/' \ | |
| sed 's/☐/\[ \]/' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment