mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Merge branch 'main' into fix-auto-reload
This commit is contained in:
commit
9e3e1a5c23
6 changed files with 120 additions and 16 deletions
|
|
@ -94,12 +94,14 @@ which you map the signals to your plugin logic. Let's take a simple example::
|
|||
your ``register`` callable or they will be garbage-collected before the
|
||||
signal is emitted.
|
||||
|
||||
If multiple plugins connect to the same signal, plugins will be executed in the
|
||||
order they are connected. With ``PLUGINS`` setting, order will be as defined in
|
||||
the setting. If you rely on auto-discovered namespace plugins, no ``PLUGINS``
|
||||
setting, they will be connected in the same order they are discovered (same
|
||||
order as ``pelican-plugins`` output). If you want to specify the order
|
||||
explicitly, disable auto-discovery by defining ``PLUGINS`` in the desired order.
|
||||
If multiple plugins connect to the same signal, plugins will be invoked in the
|
||||
order they are registered. When the ``PLUGINS`` setting is defined, plugin
|
||||
invocation order will be the order in which the plugins are listed in the
|
||||
``PLUGINS`` setting. If you rely on auto-discovered namespace plugins and have
|
||||
no ``PLUGINS`` setting defined, plugins will be invoked in the same order that
|
||||
they are discovered (the same order as listed in the output of the
|
||||
``pelican-plugins`` command). If you want to specify the order explicitly,
|
||||
disable auto-discovery by defining ``PLUGINS`` in the desired order.
|
||||
|
||||
Namespace plugin structure
|
||||
--------------------------
|
||||
|
|
|
|||
|
|
@ -292,7 +292,14 @@ Basic settings
|
|||
|
||||
A list of tags for Typogrify to ignore. By default Typogrify will ignore
|
||||
``pre`` and ``code`` tags. This requires that Typogrify version 2.0.4 or
|
||||
later is installed
|
||||
later is installed.
|
||||
|
||||
.. data:: TYPOGRIFY_OMIT_FILTERS = []
|
||||
|
||||
A list of Typogrify filters to skip. Allowed values are: ``'amp'``,
|
||||
``'smartypants'``, ``'caps'``, ``'initial_quotes'``, ``'widont'``. By
|
||||
default, no filter is omitted (in other words, all filters get applied). This
|
||||
setting requires that Typogrify version 2.1.0 or later is installed.
|
||||
|
||||
.. data:: TYPOGRIFY_DASHES = 'default'
|
||||
|
||||
|
|
|
|||
|
|
@ -648,11 +648,22 @@ class Readers(FileStampDataCacher):
|
|||
smartypants.Attr.default |= smartypants.Attr.w
|
||||
|
||||
def typogrify_wrapper(text):
|
||||
"""Ensures ignore_tags feature is backward compatible"""
|
||||
"""Ensure compatibility with older versions of Typogrify.
|
||||
|
||||
The 'TYPOGRIFY_IGNORE_TAGS' and/or 'TYPOGRIFY_OMIT_FILTERS'
|
||||
settings will be ignored if the installed version of Typogrify
|
||||
doesn't have the corresponding features."""
|
||||
try:
|
||||
return typogrify(text, self.settings["TYPOGRIFY_IGNORE_TAGS"])
|
||||
return typogrify(
|
||||
text,
|
||||
self.settings["TYPOGRIFY_IGNORE_TAGS"],
|
||||
**{f: False for f in self.settings["TYPOGRIFY_OMIT_FILTERS"]},
|
||||
)
|
||||
except TypeError:
|
||||
return typogrify(text)
|
||||
try:
|
||||
typogrify(text, self.settings["TYPOGRIFY_IGNORE_TAGS"])
|
||||
except TypeError:
|
||||
return typogrify(text)
|
||||
|
||||
if content:
|
||||
content = typogrify_wrapper(content)
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ DEFAULT_CONFIG = {
|
|||
"ARTICLE_PERMALINK_STRUCTURE": "",
|
||||
"TYPOGRIFY": False,
|
||||
"TYPOGRIFY_IGNORE_TAGS": [],
|
||||
"TYPOGRIFY_OMIT_FILTERS": [],
|
||||
"TYPOGRIFY_DASHES": "default",
|
||||
"SUMMARY_END_SUFFIX": "…",
|
||||
"SUMMARY_MAX_LENGTH": 50,
|
||||
|
|
|
|||
|
|
@ -409,15 +409,98 @@ class RstReaderTest(ReaderTest):
|
|||
except ImportError:
|
||||
return unittest.skip("need the typogrify distribution")
|
||||
|
||||
def test_typogrify_ignore_filters(self):
|
||||
try:
|
||||
# typogrify should be able to ignore user specified filters.
|
||||
page = self.read_file(
|
||||
path="article_with_code_block.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["amp"],
|
||||
)
|
||||
expected = (
|
||||
"<p>An article with some code</p>\n"
|
||||
'<div class="highlight"><pre><span></span>'
|
||||
'<span class="n">x</span>'
|
||||
' <span class="o">&</span>'
|
||||
' <span class="n">y</span>\n</pre></div>\n'
|
||||
"<p>A block quote:</p>\n<blockquote>\nx "
|
||||
"& y</blockquote>\n"
|
||||
"<p>Normal:\nx & y</p>\n"
|
||||
)
|
||||
self.assertEqual(page.content, expected)
|
||||
|
||||
page = self.read_file(
|
||||
path="article.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["smartypants"],
|
||||
)
|
||||
expected = (
|
||||
'<p><span class="caps">THIS</span> is some content. '
|
||||
"With some stuff to "typogrify"...</p>\n"
|
||||
'<p>Now with added support for <abbr title="three letter '
|
||||
'acronym"><span class="caps">TLA</span></abbr>.</p>\n'
|
||||
)
|
||||
self.assertEqual(page.content, expected)
|
||||
|
||||
page = self.read_file(
|
||||
path="article.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["caps"],
|
||||
)
|
||||
expected = (
|
||||
"<p>THIS is some content. "
|
||||
"With some stuff to “typogrify”…</p>\n"
|
||||
'<p>Now with added support for <abbr title="three letter '
|
||||
'acronym">TLA</abbr>.</p>\n'
|
||||
)
|
||||
self.assertEqual(page.content, expected)
|
||||
|
||||
page = self.read_file(
|
||||
path="article.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["initial_quotes"],
|
||||
)
|
||||
expected = (
|
||||
'<p><span class="caps">THIS</span> is some content. '
|
||||
"With some stuff to “typogrify”…</p>\n"
|
||||
'<p>Now with added support for <abbr title="three letter '
|
||||
'acronym"><span class="caps">TLA</span></abbr>.</p>\n'
|
||||
)
|
||||
self.assertEqual(page.content, expected)
|
||||
|
||||
page = self.read_file(
|
||||
path="article.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["widont"],
|
||||
)
|
||||
expected = (
|
||||
'<p><span class="caps">THIS</span> is some content. '
|
||||
"With some stuff to "
|
||||
"“typogrify”…</p>\n<p>Now with added "
|
||||
'support for <abbr title="three letter acronym">'
|
||||
'<span class="caps">TLA</span></abbr>.</p>\n'
|
||||
)
|
||||
self.assertEqual(page.content, expected)
|
||||
|
||||
page = self.read_file(
|
||||
path="article.rst",
|
||||
TYPOGRIFY=True,
|
||||
TYPOGRIFY_OMIT_FILTERS=["this-filter-does-not-exists"],
|
||||
)
|
||||
self.assertRaises(TypeError)
|
||||
except ImportError:
|
||||
return unittest.skip("need the typogrify distribution")
|
||||
except TypeError:
|
||||
return unittest.skip("need typogrify version 2.1.0 or later")
|
||||
|
||||
def test_typogrify_ignore_tags(self):
|
||||
try:
|
||||
# typogrify should be able to ignore user specified tags,
|
||||
# but tries to be clever with widont extension
|
||||
# typogrify should be able to ignore user specified tags.
|
||||
page = self.read_file(
|
||||
path="article.rst", TYPOGRIFY=True, TYPOGRIFY_IGNORE_TAGS=["p"]
|
||||
)
|
||||
expected = (
|
||||
"<p>THIS is some content. With some stuff to "
|
||||
"<p>THIS is some content. With some stuff to "
|
||||
""typogrify"...</p>\n<p>Now with added "
|
||||
'support for <abbr title="three letter acronym">'
|
||||
"TLA</abbr>.</p>\n"
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ dependencies = [
|
|||
"feedgenerator>=2.1.0",
|
||||
"jinja2>=3.1.2",
|
||||
"ordered-set>=4.1.0",
|
||||
"pygments>=2.16.1",
|
||||
"pygments>=2.16.1,<2.19.0",
|
||||
"python-dateutil>=2.8.2",
|
||||
"rich>=13.6.0",
|
||||
"unidecode>=1.3.7",
|
||||
|
|
@ -82,13 +82,13 @@ dev = [
|
|||
"jinja2>=3.1.2",
|
||||
"lxml>=4.9.3",
|
||||
"markdown>=3.5.1",
|
||||
"typogrify>=2.0.7",
|
||||
"typogrify>=2.1.0",
|
||||
"sphinx>=7.1.2",
|
||||
"sphinxext-opengraph>=0.9.0",
|
||||
"furo==2023.9.10",
|
||||
"livereload>=2.6.3",
|
||||
"psutil>=5.9.6",
|
||||
"pygments>=2.16.1",
|
||||
"pygments>=2.16.1,<2.19.0",
|
||||
"pytest>=7.4.3",
|
||||
"pytest-cov>=4.1.0",
|
||||
"pytest-sugar>=0.9.7",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue