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 19:19:13 +0100
commit534ac4829764f317cf2fbc4a18354fcc998c1425 (patch)
treec85c1df220ea6c3a87f9820106ba5a06e9ec9394 /docs/ref/utils.txt
parent7bb741d787ba360a9f0d490db92e22e0d28204ed (diff)
Refs #34140 -- Applied rst code-block to non-Python examples.
Thanks to J.V. Zammit, Paolo Melchiorre, and Mariusz Felisiak for reviews.
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 5591dfc70f..8cb360d47c 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(
@@ -655,9 +657,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
@@ -797,7 +801,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)
@@ -843,13 +849,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'