delimiters are not always 2 in length - $ being the exception. Also we have to make sure to handle both $ and $$ delimiters. Not proud of this solution but can't think of anything simpler right now - will come back to this later hopefully.