提交 eecf05f0 编写于 作者: B Ben Darnell

escape: Fix doc formatting

上级 568897d2
...@@ -290,24 +290,24 @@ def linkify(text, shorten=False, extra_params="", ...@@ -290,24 +290,24 @@ def linkify(text, shorten=False, extra_params="",
* ``shorten``: Long urls will be shortened for display. * ``shorten``: Long urls will be shortened for display.
* ``extra_params``: Extra text to include in the link tag, or a callable * ``extra_params``: Extra text to include in the link tag, or a callable
taking the link as an argument and returning the extra text taking the link as an argument and returning the extra text
e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``, e.g. ``linkify(text, extra_params='rel="nofollow" class="external"')``,
or:: or::
def extra_params_cb(url): def extra_params_cb(url):
if url.startswith("http://example.com"): if url.startswith("http://example.com"):
return 'class="internal"' return 'class="internal"'
else: else:
return 'class="external" rel="nofollow"' return 'class="external" rel="nofollow"'
linkify(text, extra_params=extra_params_cb) linkify(text, extra_params=extra_params_cb)
* ``require_protocol``: Only linkify urls which include a protocol. If * ``require_protocol``: Only linkify urls which include a protocol. If
this is False, urls such as www.facebook.com will also be linkified. this is False, urls such as www.facebook.com will also be linkified.
* ``permitted_protocols``: List (or set) of protocols which should be * ``permitted_protocols``: List (or set) of protocols which should be
linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp", linkified, e.g. ``linkify(text, permitted_protocols=["http", "ftp",
"mailto"])``. It is very unsafe to include protocols such as "mailto"])``. It is very unsafe to include protocols such as
``javascript``. ``javascript``.
""" """
if extra_params and not callable(extra_params): if extra_params and not callable(extra_params):
extra_params = " " + extra_params.strip() extra_params = " " + extra_params.strip()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册