mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Tell smartypants to also process " entities
This is necessary because Docutils has already replaced double quotes with " HTML entities by the time the typogrify filter is applied.
This commit is contained in:
parent
9152e021e2
commit
0949fa62ec
2 changed files with 10 additions and 3 deletions
|
|
@ -467,6 +467,13 @@ class Readers(FileStampDataCacher):
|
||||||
# eventually filter the content with typogrify if asked so
|
# eventually filter the content with typogrify if asked so
|
||||||
if self.settings['TYPOGRIFY']:
|
if self.settings['TYPOGRIFY']:
|
||||||
from typogrify.filters import typogrify
|
from typogrify.filters import typogrify
|
||||||
|
import smartypants
|
||||||
|
|
||||||
|
# Tell `smartypants` to also replace " HTML entities with
|
||||||
|
# smart quotes. This is necessary because Docutils has already
|
||||||
|
# replaced double quotes with said entities by the time we run
|
||||||
|
# this filter.
|
||||||
|
smartypants.Attr.default |= smartypants.Attr.w
|
||||||
|
|
||||||
def typogrify_wrapper(text):
|
def typogrify_wrapper(text):
|
||||||
"""Ensures ignore_tags feature is backward compatible"""
|
"""Ensures ignore_tags feature is backward compatible"""
|
||||||
|
|
|
||||||
|
|
@ -121,7 +121,7 @@ class RstReaderTest(ReaderTest):
|
||||||
page = self.read_file(path='article.rst', TYPOGRIFY=True)
|
page = self.read_file(path='article.rst', TYPOGRIFY=True)
|
||||||
expected = (
|
expected = (
|
||||||
'<p><span class="caps">THIS</span> is some content. '
|
'<p><span class="caps">THIS</span> is some content. '
|
||||||
'With some stuff to "typogrify"…</p>\n'
|
'With some stuff to “typogrify”…</p>\n'
|
||||||
'<p>Now with added support for <abbr title="three letter '
|
'<p>Now with added support for <abbr title="three letter '
|
||||||
'acronym"><span class="caps">TLA</span></abbr>.</p>\n')
|
'acronym"><span class="caps">TLA</span></abbr>.</p>\n')
|
||||||
|
|
||||||
|
|
@ -146,8 +146,8 @@ class RstReaderTest(ReaderTest):
|
||||||
TYPOGRIFY=True)
|
TYPOGRIFY=True)
|
||||||
expected = ('<p class="first last">Multi-line metadata should be'
|
expected = ('<p class="first last">Multi-line metadata should be'
|
||||||
' supported\nas well as <strong>inline'
|
' supported\nas well as <strong>inline'
|
||||||
' markup</strong> and stuff to "typogrify'
|
' markup</strong> and stuff to “typogrify'
|
||||||
'"…</p>\n')
|
'”…</p>\n')
|
||||||
|
|
||||||
self.assertEqual(page.metadata['summary'], expected)
|
self.assertEqual(page.metadata['summary'], expected)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue