class documentation
An HTMLParser that only allows a very limited subset of HTML.
| Method | __init__ |
Initialise the parser. |
| Method | handle |
Append any character references. |
| Method | handle |
Append any data inside tags after escaping it. |
| Method | handle |
Append the end tag only if it is in the allowed list. |
| Method | handle |
Append any named character. |
| Method | handle |
Append a self-closing tag if it is a new line. |
| Method | handle |
Append a start tag found in the HTML if it is in the allowed list. |
| Instance Variable | output |
Undocumented |
Append a start tag found in the HTML if it is in the allowed list.
This is called by the base class when a start tag is found. We only append the tag if it is our allowed list. We re-write the tag so no extra attributes can be added.
No tags can have attributes except for a tags, why only allow href. We then append target="_blank" rel="noopener noreferrer" to ensure the link opens in a new window.
| Parameters | |
tag:str | the tag name |
attrs:list[ | the attributes for the tag. |