   sanitized
 
 @formatBody = (format, body, leaveTeX = false) ->
+  [body, math] = preprocessKaTeX body unless leaveTeX
   if format of formats
     body = formats[format] body, false
   else
     console.warn "Unrecognized format '#{format}'"
-  sanitize postprocess body, leaveTeX
+  body = postprocessKaTeX body, math unless leaveTeX
+  sanitize postprocessCoauthorLinks body
 
 @formatTitle = (format, title, leaveTeX = false) ->
+  [title, math] = preprocessKaTeX title unless leaveTeX
   if format of formats
     title = formats[format] title, true
   else

    ## Escape all characters that can be (in particular, _s) that appear
    ## inside math mode, to prevent Marked from processing them.
    ## The Regex is exactly marked.js's inline.escape.
    text = replaceMathBlocks text, (block) ->
      block.replace /[\\`*{}\[\]()#+\-.!_]/g, '\\$&'
    #marked.Lexer.rules = {text: /^[^\n]+/} if title
    if title  ## use "single-line" version of Markdown
      text = markdownInline text

      .replace /</g, '&lt;'
      .replace />/g, '&gt;'
      "<SPAN CLASS='katex-error' TITLE='#{title}'>#{latex}</SPAN>"

jsdiff = require 'diff'

