summaryrefslogtreecommitdiff
path: root/doc/source
diff options
context:
space:
mode:
authorLeonard Richardson <leonardr@segfault.org>2021-12-21 12:57:04 -0500
committerLeonard Richardson <leonardr@segfault.org>2021-12-21 12:57:04 -0500
commit3ac8524a1263f170ae0a9096d255d3e28aa76340 (patch)
treee6aab155135f553f3043a425dcf8e61884091919 /doc/source
parent792a9e485e1b110534345a4f96fd65099879421e (diff)
It's now possible to customize the way output is indented by
providing a value for the 'indent' argument to the Formatter constructor. The 'indent' argument works very similarly to the argument of the same name in the Python standard library's json.dump() method. [bug=1955497]
Diffstat (limited to 'doc/source')
-rw-r--r--doc/source/index.rst8
1 files changed, 8 insertions, 0 deletions
diff --git a/doc/source/index.rst b/doc/source/index.rst
index 66bd03e..67251e8 100644
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -2331,6 +2331,14 @@ attribute value::
# A LINK
# </a>
+Here's a formatter that increases the indentation when pretty-printing::
+
+ formatter = HTMLFormatter(indent=8)
+ print(link_soup.a.prettify(formatter=formatter))
+ # <a href="http://example.com/?foo=val1&bar=val2">
+ # A link
+ # </a>
+
Subclassing ``HTMLFormatter`` or ``XMLFormatter`` will give you even
more control over the output. For example, Beautiful Soup sorts the
attributes in every tag by default::