#!/bin/sh
#
# HTMLIZE_M.sh
# Make all the Matlab (*.m) files in a directory have parallel *.m.html files that are pygmentized (syntax colored and hyperlinked within the directory)
#
# 2014-04-11 Dan Ellis dpwe@ee.columbia.edu

# To get the cross-links to work, you must have the following installed
# 
#  - exuberant ctags ( sudo apt-get install exuberant-ctags )
#  - latest pygmentize (1.6) ( sudo apt-get install python-pip; sudo su - ; pip install --upgrade pygments )
#  - python-ctags ( sudo su - ; pip install python-ctags )

# Generate the cross-file hyperlink information
ctags -n *.m

# Run pygmentize on all those *.m files
for f in *.m; do
  echo "pygmentizing $f -> $f.html"
  pygmentize -l matlab -f html -O full,tagsfile=tags,anchorlinenos=1,lineanchors=1,tagurlformat='%(fname)s%(fext)s.html' -o $f.html $f
done

exit 0
