The XML filter is designed to capture XML content, comments, and even attributes. It allows for filtering out specific tags, and you can even filter them out with CSS selectors (even though this is XML content :slightly_smiling:).
When first in the chain, the XML filter will look for the encoding of the file in its header and convert the buffer to Unicode. It will assume
utf-8 if no encoding header is found, and the user has not overridden the fallback encoding.
The HTML filter uses BeautifulSoup4 to convert the Unicode content to XML structure. Tag content is as one block for the whole file. If enabled, the XML filter will also return chunks for comments and even attributes. Each type of text chunk is returned with their own category type.
Tags can be captured or ignored with the
ignores options. These options work by employing CSS selectors to target the tags. The CSS selectors are based on a limited subset of CSS4 selectors.
matrix: - name: xml pipeline: - pyspelling.filters.xml: comments: false attributes: - some-data ignores: - :matches(ignore_tag, [ignore_attribute]) sources: - site/*.xml
The CSS selectors are based on a limited subset of CSS4 selectors. Support is provided via Soup Sieve. Please reference Soup Sieve's documentation for more info.
| ||bool|| ||Include comment text in the output.|
| ||[string]|| ||Attributes whose content should be included in the output.|
| ||[string]|| ||CSS style selectors that identify tags to ignore. Child tags will not be crawled.|
| ||[string]|| ||CSS style selectors used to narrow which tags that text is collected from. Unlike |
| ||dict|| ||Dictionary containing key value pairs of namespaces to use for CSS selectors (equivalent to |
| ||[string]|| ||Tags to break on for context. Causes more calls to the spell checker.|
matrix: - name: xml pipeline: - pyspelling.filters.xml: namespaces: "": http://www.w3.org/1999/xhtml svg: http://www.w3.org/2000/svg xlink: http://www.w3.org/1999/xlink
HTML returns text with the following categories.
| ||Text captured from XML tags.|
| ||Text captured from XML attributes.|
| ||Text captured from XML comments.|