本文整理匯總了Python中bs4.dammit.EntitySubstitution.substitute_html方法的典型用法代碼示例。如果您正苦於以下問題:Python EntitySubstitution.substitute_html方法的具體用法?Python EntitySubstitution.substitute_html怎麽用?Python EntitySubstitution.substitute_html使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bs4.dammit.EntitySubstitution
的用法示例。
在下文中一共展示了EntitySubstitution.substitute_html方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: substitute_html
# 需要導入模塊: from bs4.dammit import EntitySubstitution [as 別名]
# 或者: from bs4.dammit.EntitySubstitution import substitute_html [as 別名]
def substitute_html(cls, ns):
return cls._substitute_if_appropriate(
ns, EntitySubstitution.substitute_html)
示例2: __init__
# 需要導入模塊: from bs4.dammit import EntitySubstitution [as 別名]
# 或者: from bs4.dammit.EntitySubstitution import substitute_html [as 別名]
def __init__(
self, language=None, entity_substitution=None,
void_element_close_prefix='/', cdata_containing_tags=None,
):
"""Constructor.
:param language: This should be Formatter.XML if you are formatting
XML markup and Formatter.HTML if you are formatting HTML markup.
:param entity_substitution: A function to call to replace special
characters with XML/HTML entities. For examples, see
bs4.dammit.EntitySubstitution.substitute_html and substitute_xml.
:param void_element_close_prefix: By default, void elements
are represented as <tag/> (XML rules) rather than <tag>
(HTML rules). To get <tag>, pass in the empty string.
:param cdata_containing_tags: The list of tags that are defined
as containing CDATA in this dialect. For example, in HTML,
<script> and <style> tags are defined as containing CDATA,
and their contents should not be formatted.
"""
self.language = language
self.entity_substitution = entity_substitution
self.void_element_close_prefix = void_element_close_prefix
self.cdata_containing_tags = self._default(
language, cdata_containing_tags, 'cdata_containing_tags'
)