Yes, I love what you’ve done here.
All, @Bernard-0 has developed a comprehensive approach for processing Tinderbox notes through Pandoc. As noted, his attached file is primarily set up for processing markdown (.md) files. I can attest, however, that it is simple enough to also process .html files using pandoc. Also, PLEASE don’t let all the configuration options in the file intimidate you (it certainly intimidated me when I first look at it). Pandoc is extremely powerful, you can do a lot with it. However, all the options may create a paradox of choice, and with too much choice you may end up doing nothing.
To this end, I’d like to add to this thread a barebones TBX to Pandoc file/process. Here are the steps to use it.
Besure to INSTALL PANDOC
First off, huge thanks to @rtalexander who taught me all this.
- Launch your terminal, use the built-in one with your mac found in Utilities or install https://iterm2.com/ which is a VERY nice enhanced terminal
- Install Homebrew, https://brew.sh/. Homebrew is a shell to help run command-line apps on your Mac.
- Install Pandoc, once you have Homebrew installed type this in your terminal “brew install pandoc”. Homebrew will automatically go out and install the latest version of pandoc. NOTE: this same step can be used to update pandoc too.
#TEST PANDOC
Now that you have pandoc ready to go you can test it out.
- Create a pandoc scratchpad directory for yourself, a place to process your files. The easiest way to do this is from the Finder (you can do it from the terminal tool, simply type “mktdir pandocSP” at the root level). I put my at the home directory of my Mac using finder. the path to this directory is /users/mysernmae/pandocSP/.
- Make sure you’re in your new directory, type pwd to see what dir your in. Type “cd pandocSP” if you need to move yourself to your new directory.
- Test processing a sample file in pandoc.
Here are two sample files you can try, one markdown file and one HTML file. Download and uncompress these files in your pandocSP directory.
PandocTestFiles.zip (45.7 KB)
Unzip this file and put the files in your pandocSP dir.
a. Convert markdown to PowerPoint
In the command-line type: “pandoc -s PRESTEST.md -o PRESTEST.pptx”
This will create a PPTX file.
b. Convert HTML to DOCX
In the command-line type: “pandoc -s SAMPLEFILE.html -o SAMPLEFILE.docx”
c. Covnert HTML to PDF*
If you want to do this, you first need to install basictex
, from your command line, type brew install basictex
and then follow the prompts. Once it is installed you can type in the In the command-line type: “pandoc -s SAMPLEFILE.html -o SAMPLEFILE.pdf”.
*Note: converting the PDF is taking a two-step process. Need to try to debug this with @Bernard-0 or @rtalexander
The steps above will convert the the files. the “-s” flag is telling pandoc to create a standalone file. The “-0” flag is telling pandoc to create and output files, e.g. “.pptx” or “.docx” or “.pdf”.
You see? Pandoc converted the two files with the above commands.
Going through the steps above makes you a command-line user. Congrats!!!
#Now Use Tinderbox to Do It
Your next step is to have Tinderbox pass the pandoc flags and file names to pandoc. You do this using a stamp that will 1) create a file in your dir, 2) paste your notes into this file, 3) construct the files names and pandoc run command, and 4) run the run command.
Here is the stamp:
var theExportedFile;
var theText;
var theCovertedFile;
theExportedFile=$exportDir("TBXConfigNote")+$ExportFileName+$fileType;
theCovertedFile=$exportDir("TBXConfigNote")+$ExportFileName+$convertToType;
$theConversionCommand=$pandocDir("TBXConfigNote")+"pandoc -s "+theExportedFile+" -o "+ theCovertedFile;
theText=exportedString(this,$HTMLExportTemplate);
runCommand("pbcopy ",theText);
runCommand("touch " + theExportedFile);
runCommand("pbpaste > " + theExportedFile);
runCommand($theConversionCommand);
The pbcopy command line copys the text of your notes to the clipboard.
The touch command line creates a file on your Mac.
The pbpaste command line pastes the clipboard to the newly created file.
The conversation command line runs pandoc.
Here is a sample TBX and sample files you can play with to make this work.
PandocTestFiles.zip (45.7 KB)
TBX L _ Barefones TBX and Pandoc Example.tbx (111.5 KB)
The only difference between this file and @Bernard-0’s is that I’ve removed all the niceties, e.g. changing of fonts, templates, using the bibliography etc. Tinderbox and Pandoc together, as @bernard demonstrates, can do some amazing things together. To enhance the pandoc conversion you simply need to pass in the command line additional refinement flags to enhance the standalone file and output file, like --toc which adds a table fo contents to your word doc. enhance the Tinderbox side you can add file name version control attributes, have it remove the source files, and a whole bunch of other things (will save this easter eggs for later).
NOTE: When working with markdown you need to make sure there is at least one space after each bullet on your slide notes and one space before the speaker notes.