Skip to content

Instantly share code, notes, and snippets.

@tinpark tinpark/p2b.sh
Created May 29, 2019

Embed
What would you like to do?
p2b.sh push your file to blot, with citations rendered correctly
#!/bin/sh
# p2b.sh
#
#
# Created by PARKER Martin on 22/05/2019.
# This takes your markdown document, renders it to HTML and publishes it straight to blot.im
# dependencies,
# pandoc http://www.pandoc.org/
# pandoc-citeproc https://github.com/jgm/pandoc-citeproc
# a pucker .bib file (made with zotero or something) https://www.zotero.org/download/
# a bib csl style, download from here: https://www.zotero.org/styles/
# something nice to write markdown with, atom is lovely: https://atom.io/
######USAGE#######
# cd to/the/directory/with/your/markdown
# bash /path/to/script/p2b.sh inFileName.md
# eg: bash ~/Dropbox/shellScripts/p2b.sh example.md
# Set the path to your blot directory, change this here if it's different
blotPath=~/Dropbox/Apps/Blot
# set and forget these paths, tell the script where you keep your bibliography, bib style etc.
bibPath=~/Dropbox/bibliography/bibliography.bib
cslPath=~/Dropbox/bibliography/journal-of-new-music-research.csl
# source file to convert to html
inputName=$1
# output filename
outputName="${1%.*}.html"
# get the directory where you're working
dir="$PWD"
# check if blot has images and files folder, if not, make them, if you have other folders for stuff add them here
if [ ! -d "$blotPath/images" ] ; then mkdir "$blotPath/images"; fi
if [ ! -d "$blotPath/files" ]; then mkdir "$blotPath/files"; fi
# run pandoc script
pandoc "$inputName" --metadata link-citations=true --toc --filter pandoc-citeproc --bibliography="$bibPath" --csl="$cslPath" -s --metadata --mathjax -f markdown -t html5 -o "$blotPath/$outputName"
# copy files that may be linked in your post from your working directory to blot, if you have other folders of other things, add them here.
# if you don't want individual images to show up as blog posts, be sure to name them with an _ (underscore) in front, e.g. _image.png.
cp -a "$dir/images/" "$blotPath/images/"
cp -a "$dir/files/" "$blotPath/files/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.