本文整理汇总了Python中webhelpers.html.HTML.br方法的典型用法代码示例。如果您正苦于以下问题:Python HTML.br方法的具体用法?Python HTML.br怎么用?Python HTML.br使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webhelpers.html.HTML
的用法示例。
在下文中一共展示了HTML.br方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_html
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import br [as 别名]
def test_html():
a = HTML.a(href='http://mostlysafe\" <tag', c="Bad <script> tag")
eq_(a,
u'<a href="http://mostlysafe" <tag">Bad <script> tag</a>')
img = HTML.img(src='http://some/image.jpg')
eq_(img, u'<img src="http://some/image.jpg" />')
br = HTML.br()
eq_(u'<br />', br)
示例2: markdown
# 需要导入模块: from webhelpers.html import HTML [as 别名]
# 或者: from webhelpers.html.HTML import br [as 别名]
import re
from webhelpers.html import HTML, escape, literal, lit_sub
import webhelpers.textile as textile
import webhelpers.markdown as _markdown
__all__ = [
"markdown",
"textilize",
"nl2br",
"format_paragraphs",
]
_universal_newline_rx = re.compile(R"\r\n|\n|\r") # All types of newline.
_paragraph_rx = re.compile(R"\n{2,}") # Paragraph break: 2 or more newlines.
br = HTML.br() + "\n"
def markdown(text, **kwargs):
"""Format the text to HTML with MarkDown formatting.
This function uses the `Python MarkDown library
<http://www.freewisdom.org/projects/python-markdown/>`_
which is included with WebHelpers. It does not include extensions
due to circular import issues. If you need the footnotes or RSS
extensions, use the full Markdown package instead.
IMPORTANT:
If your source text is untrusted and may contain malicious HTML markup,
pass ``safe_mode="escape"`` to escape it, ``safe_mode="replace"`` to
replace it with a scolding message, or ``safe_mode="remove"`` to strip it.