Skip to content

Instantly share code, notes, and snippets.

@mcleonard
Created February 1, 2016 23:00
Show Gist options
  • Save mcleonard/97ad7f6338d3e3c4ad06 to your computer and use it in GitHub Desktop.
Save mcleonard/97ad7f6338d3e3c4ad06 to your computer and use it in GitHub Desktop.
A shell script for processing a Jupyter notebook Markdown file for use with Pelican
#!/bin/bash
FILE=$1
FILENAME="${FILE%%.*}"
FILE_DIR="${FILENAME}_files"
if [ -d $FILE_DIR ]; then
# When converting a notebook to markdown, all the images in the markdown file link to the files
# folder created when converting. We need to replace the file folder with
# the static images folder used by Pelican.
sed -i "" "s/${FILE_DIR}/images/g" $1
# Also copy images from file directory to images
cp $FILE_DIR/* images
rm -r $FILE_DIR
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment