Add error checking for katex parser

The preview window would previously crash if an invalid LaTeX string was
passed to katex. Now there are explict error checks, and if it is unable
to process the given string, the string itself will be previewed as it
is.