當前位置: 首頁>>代碼示例>>Python>>正文


Python HTML.br方法代碼示例

本文整理匯總了Python中webhelpers2.html.HTML.br方法的典型用法代碼示例。如果您正苦於以下問題:Python HTML.br方法的具體用法?Python HTML.br怎麽用?Python HTML.br使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在webhelpers2.html.HTML的用法示例。


在下文中一共展示了HTML.br方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_html

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.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&#34; &lt;tag">Bad &lt;script&gt; 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)
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:11,代碼來源:test_html.py

示例2: test_html

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import br [as 別名]
 def test_html(self):
     a = HTML.a(href='http://mostlysafe\" <tag', c="Bad <script> tag")
     assert a == '<a href="http://mostlysafe&#34; &lt;tag">Bad &lt;script&gt; tag</a>'
     
     img = HTML.img(src="http://some/image.jpg")
     assert img == '<img src="http://some/image.jpg" />'
     
     br = HTML.br()
     assert "<br />" == br
開發者ID:jManji,項目名稱:Trivia,代碼行數:11,代碼來源:test_html.py

示例3: render

# 需要導入模塊: from webhelpers2.html import HTML [as 別名]
# 或者: from webhelpers2.html.HTML import br [as 別名]
from webhelpers2.html import HTML, escape, literal, lit_sub

# render() and sanitize() are imported from the private module 'render'.
from webhelpers2.html.render import render, sanitize

__all__ = [
    "format_paragraphs",
    "nl2br",
    "render",
    "sanitize",
    ]

_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 nl2br(text):
    """Insert a <br /> before each newline.
    """
    if text is None:
        return literal("")
    text = lit_sub(_universal_newline_rx, "\n", text)
    text = HTML(text).replace("\n", br)
    return text

def format_paragraphs(text, preserve_lines=False):
    """Convert text to HTML paragraphs.

    ``text``:
        the text to convert.  Split into paragraphs at blank lines (i.e.,
開發者ID:aodag,項目名稱:WebHelpers2,代碼行數:32,代碼來源:converters.py


注:本文中的webhelpers2.html.HTML.br方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。