Created
October 23, 2022 23:22
-
-
Save laffan/b3eecbac8c6314f2bc343fc7681ce8fe to your computer and use it in GitHub Desktop.
Revisions
-
laffan created this gist
Oct 23, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ #!/usr/bin/env bash # MarkdownToWord # -------------- # Searches for markdown file in parent directory, then uses pandoc to export it # along with with bibtex citations to a word document on your desktop. # Intended to be used with a Zotero --> Obsidian --> Word workflow # # TO USE # Insert your own username on line 43, make sure md and csl files are within parent # directory somewhere and run : # $ ./mdToWordNoComments.sh {mdFilename} {cslFilename} {exportFilename} echo -e ">> MarkdownToWord" if ( test -z "$1" ) then echo -e "🚨 No note specified" exit 1 fi if ( test -z "$2" ) then echo -e "🚨 No template specified" exit 1 fi if ( test -z "$3" ) then echo -e "🚨 No output filename specified" exit 1 fi filePath=$(cd .. && find ~+ -type f -name "$1.md";) #create temp file # tempFile=$(cp $filePath temp.md) touch temp.md # strip comments sed "/%%/,/%%/d" "$filePath" >> temp.md templatePath=$(cd .. && find ~+ -type f -name "$2.*";) bibPath=$(cd .. && find ~+ -type f -name "zotero.bib";) outputPath="/Users/{yourUsername}/Desktop/$3.docx" printf "=====================================\n" printf " + File name: $1\n" printf " + File path: $filePath\n" printf " + Bib path: $bibPath\n" printf " + Template path: $templatePath\n" printf " + Output path: $outputPath\n" printf "=====================================\n" pandoc "temp.md" --bibliography "$bibPath" --citeproc --csl "$templatePath" -o "$outputPath" rm temp.md