summaryrefslogtreecommitdiff
path: root/docs/ref/utils.txt
diff options
context:
space:
mode:
authorCarlton Gibson <carlton.gibson@noumenal.es>2023-02-09 16:48:46 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-02-10 21:12:06 +0100
commitb784768eef75afb32f6d2ce7166551a528bce0ec (patch)
treea375a57a50f1766538ea8a62ec49bda352d7f2b9 /docs/ref/utils.txt
parent4a89aa25c91e520c247aee428782274dcf10ffd0 (diff)
[4.2.x] Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for reviews. Backport of 534ac4829764f317cf2fbc4a18354fcc998c1425 from main.
Diffstat (limited to 'docs/ref/utils.txt')
-rw-r--r--docs/ref/utils.txt22
1 files changed, 16 insertions, 6 deletions
diff --git a/docs/ref/utils.txt b/docs/ref/utils.txt
index b1a08dc0e1..75e68aeed2 100644
--- a/docs/ref/utils.txt
+++ b/docs/ref/utils.txt
@@ -298,7 +298,9 @@ The functions defined in this module share the following properties:
.. module:: django.utils.feedgenerator
:synopsis: Syndication feed generation library -- used for generating RSS, etc.
-Sample usage::
+Sample usage:
+
+.. code-block:: pycon
>>> from django.utils import feedgenerator
>>> feed = feedgenerator.Rss201rev2Feed(
@@ -660,9 +662,11 @@ escaping HTML.
Escapes all HTML/XML special characters with their Unicode escapes, so
value is safe for use with JavaScript. Also wraps the escaped JSON in a
``<script>`` tag. If the ``element_id`` parameter is not ``None``, the
- ``<script>`` tag is given the passed id. For example::
+ ``<script>`` tag is given the passed id. For example:
+
+ .. code-block:: pycon
- >> json_script({"hello": "world"}, element_id="hello-data")
+ >>> json_script({"hello": "world"}, element_id="hello-data")
'<script id="hello-data" type="application/json">{"hello": "world"}</script>'
The ``encoder``, which defaults to
@@ -806,7 +810,9 @@ appropriate entities.
For building up fragments of HTML, you should normally be using
:func:`django.utils.html.format_html` instead.
- String marked safe will become unsafe again if modified. For example::
+ String marked safe will become unsafe again if modified. For example:
+
+ .. code-block:: pycon
>>> mystr = '<b>Hello World</b> '
>>> mystr = mark_safe(mystr)
@@ -852,13 +858,17 @@ appropriate entities.
#. Replacing any whitespace or repeated dashes with single dashes.
#. Removing leading and trailing whitespace, dashes, and underscores.
- For example::
+ For example:
+
+ .. code-block:: pycon
>>> slugify(' Joel is a slug ')
'joel-is-a-slug'
If you want to allow Unicode characters, pass ``allow_unicode=True``. For
- example::
+ example:
+
+ .. code-block:: pycon
>>> slugify('你好 World', allow_unicode=True)
'你好-world'