本文整理汇总了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'
)