Skip to content

Instantly share code, notes, and snippets.

@ttscoff
Last active May 5, 2017 08:55
Show Gist options
  • Save ttscoff/24612c9e156ab42a8b0b to your computer and use it in GitHub Desktop.
Save ttscoff/24612c9e156ab42a8b0b to your computer and use it in GitHub Desktop.
A custom preprocessor for Marked 2 that will export two files after Marked does initial inclusion and processing, then cancel the processor and have Marked resume processing.
#!/bin/bash
# A custom preprocessor for Marked 2 that will export two files after Marked
# does initial inclusion and processing, then cancel the processor and have
# Marked resume processing.
# Install the latest version of MultiMarkdown:
# http://fletcherpenney.net/multimarkdown/download/
function main()
{
# MARKED_PATH contains the full path to the document opened in Marked
local filepath=$MARKED_PATH
local dir=`dirname $filepath`
local filename=`basename $filepath .$MARKED_EXT`
# create a compiled version of the Markdown in the same folder as the
# original document
cat > $dir/$filename-compiled.md
# create a lyx version in the same folder as the original document
/usr/local/bin/multimarkdown -t lyx $dir/$filename-compiled.md > $dir/$filename.lyx
# Returning "NOCUSTOM" tells Marked to skip the processor and resume rendering
echo "NOCUSTOM"
}
cat | main $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment