     text
 
 @inTag = (string, offset) ->
+  ## Known issue: `<a title=">"` looks like a terminated tag to this code.
+  ## This is why `escapeForQuotedHTML` escapes >s.
   open = string.lastIndexOf '<', offset
   if open >= 0
     close = string.lastIndexOf '>', offset


postprocessLinks = (text) ->
  text.replace urlRe, (match, offset, string) ->
    if inTag string, offset
      match
    else

      format: format
      active: if Template.currentData()?.format == format then 'active' else ''
      capitalized: capitalize format

escapeForHTML = (s) ->
  s
  .replace /&/g, '&amp;'
  .replace /</g, '&lt;'
  .replace />/g, '&gt;'

escapeForQuotedHTML = (s) ->
  escapeForHTML s
  .replace /"/g, '&quot;'

## Finds all $...$ and $$...$$ blocks, where ... properly deals with balancing
## braces (e.g. $\hbox{$x$}$) and escaped dollar signs (\$ doesn't count as $),
