   .replace /`/g, '&lsquo;'
   .replace /'/g, '&rsquo;'
   .replace /\\&/g, '&amp;'
-  .replace /\\([{}])/g, '$1'
+  .replace /\\([${}])/g, '$1'
   .replace /~/g, '&nbsp;'
   .replace /\\\s/g, ' '
   .replace /---/g, '&mdash;'

    math[i] = block
    "MATH#{i}ENDMATH"
  [text, math]

postprocessKaTeX = (text, math) ->
  replacer = (block) ->

  .replace /\n\n+/g, '\n<p>\n'
  .replace /<p>\s*(<h[1-9]>)/g, '$1'
  .replace /\[DOUBLEBACKSLASH\]/g, '\\\\'
  [tex, math]

@formats =
  markdown: (text, title) ->
