The HTML filter is designed to capture HTML content, comments, and even attributes. It allows for filtering out specific tags, and you can even filter them out with basic selectors.
When first in the chain, the HTML filter will look for the encoding of the HTML 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 HTML. Content is returned in individual chunks by block tags. While this causes more overhead, as each block is processed individually through the command line tool, it provides context for where the spelling errors are. If enabled, the HTML 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: html pipeline: - pyspelling.filters.html: comments: false attributes: - title - alt ignores: - :matches(code, pre) - a:matches(.magiclink-compare, .magiclink-commit) - span.keys - :matches(.MathJax_Preview, .md-nav__link, .md-footer-custom-text, .md-source__repository, .headerlink, .md-icon) sources: - site/*.html
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 |
| ||string|| ||Mode to use when parsing HTML: |
| ||dict|| ||Dictionary containing key value pairs of namespaces to use for CSS selectors (equivalent to |
| ||[string]|| ||Additional tags (in addition to the default, defined block tags), to break on for context. Useful for new or currently unsupported block tags.|
matrix: - name: html pipeline: - pyspelling.filters.html: mode: xhtml 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 HTML blocks.|
| ||Text captured from HTML attributes.|
| ||Text captured from HTML comments.|