![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|


Public Member Functions | |
| bool | warn_if_markup_looks_like_xml (cls, Optional[_RawMarkup] markup, int stacklevel=3) |
Static Public Attributes | |
| Pattern | LOOKS_LIKE_HTML = re.compile("<[^ +]html", re.I) |
| Pattern | LOOKS_LIKE_HTML_B = re.compile(b"<[^ +]html", re.I) |
| str | XML_PREFIX = "<?xml" |
| bytes | XML_PREFIX_B = b"<?xml" |
Protected Member Functions | |
| None | _warn (cls, int stacklevel=5) |
| None | _initialize_xml_detector (self) |
| None | _document_might_be_xml (self, str processing_instruction) |
| None | _root_tag_encountered (self, str name) |
Protected Attributes | |
| _first_processing_instruction | |
| _root_tag_name | |
Static Protected Attributes | |
| Optional | _first_processing_instruction [str] |
| Optional | _root_tag_name [str] |
A mixin class for any class (a TreeBuilder, or some class used by a TreeBuilder) that's in a position to detect whether an XML document is being incorrectly parsed as HTML, and issue an appropriate warning. This requires being able to observe an incoming processing instruction that might be an XML declaration, and also able to observe tags as they're opened. If you can't do that for a given `TreeBuilder`, there's a less reliable implementation based on examining the raw markup.
|
protected |
Call this method when encountering an XML declaration, or a "processing instruction" that might be an XML declaration. This helps Beautiful Soup detect potential issues later, if the XML document turns out to be a non-XHTML document that's being parsed as XML.
|
protected |
Call this method before parsing a document.
|
protected |
Call this when you encounter the document's root tag. This is where we actually check whether an XML document is being incorrectly parsed as HTML, and issue the warning.
|
protected |
Issue a warning about XML being parsed as HTML.
| bool bs4.builder.DetectsXMLParsedAsHTML.warn_if_markup_looks_like_xml | ( | cls, | |
| Optional[_RawMarkup] | markup, | ||
| int | stacklevel = 3 |
||
| ) |
Perform a check on some markup to see if it looks like XML that's not XHTML. If so, issue a warning. This is much less reliable than doing the check while parsing, but some of the tree builders can't do that. :param stacklevel: The stacklevel of the code calling this\ function. :return: True if the markup looks like non-XHTML XML, False otherwise.