mirror of
https://github.com/django/django.git
synced 2025-08-21 01:09:13 +00:00
Fixed #36535 -- Ensured compatibility with docutils 0.19 through 0.22.
Regression in 65ab92f6a83644bbb555d0eff3a02d8d9301aba4.
This commit is contained in:
parent
dca8284a37
commit
9cec8d9f55
@ -13,6 +13,7 @@ try:
|
||||
import docutils.core
|
||||
import docutils.nodes
|
||||
import docutils.parsers.rst.roles
|
||||
import docutils.writers
|
||||
except ImportError:
|
||||
docutils_is_available = False
|
||||
else:
|
||||
@ -78,11 +79,14 @@ def parse_rst(text, default_reference_context, thing_being_parsed=None):
|
||||
|
||||
.. default-role::
|
||||
"""
|
||||
# In docutils < 0.22, the `writer` param must be an instance. Passing a
|
||||
# string writer name like "html" is only supported in 0.22+.
|
||||
writer_instance = docutils.writers.get_writer_class("html")()
|
||||
parts = docutils.core.publish_parts(
|
||||
source % text,
|
||||
source_path=thing_being_parsed,
|
||||
destination_path=None,
|
||||
writer="html",
|
||||
writer=writer_instance,
|
||||
settings_overrides=overrides,
|
||||
)
|
||||
return mark_safe(parts["fragment"])
|
||||
|
@ -19,3 +19,5 @@ Bugfixes
|
||||
* Fixed a crash in Django 5.2 when validating a model that uses
|
||||
``GeneratedField`` or constraints composed of ``Q`` and ``Case`` lookups
|
||||
(:ticket:`36518`).
|
||||
|
||||
* Added compatibility for ``docutils`` 0.22 (:ticket:`36535`).
|
||||
|
Loading…
x
Reference in New Issue
Block a user