He repl...">

smarty: double sets of quotes not working at end · Issue #1514 · Python-Markdown/markdown (original) (raw)

The following example renders incorrectly:

import markdown

text = ''' He replied, "She said 'Hello.'" '''

html = markdown.markdown(text, extensions=['smarty']) print(html)

The output is:

<p>He replied, &ldquo;She said &lsquo;Hello.&rsquo;&ldquo;</p>

The &ldquo; at the end of this example should be &rdquo;.

The quote marks were replaced in this order:

  1. openingSingleQuotesRegex
  2. closingSingleQuotesRegex
  3. openingDoubleQuotesRegex
  4. remainingDoubleQuotesRegex

Unfortunately:

One possible way to fix this issue might be to change closingDoubleQuotesRegex to r'"(?=\s|$)' (i.e., double quote followed by whitespace or end of string). However that doesn't work in general, so a special case is likely needed.