(text: str)
| 121 | |
| 122 | |
| 123 | def _escape_attrib_html(text: str) -> str: |
| 124 | # escape attribute value |
| 125 | try: |
| 126 | if "&" in text: |
| 127 | # Only replace & when not part of an entity |
| 128 | text = RE_AMP.sub('&', text) |
| 129 | if "<" in text: |
| 130 | text = text.replace("<", "<") |
| 131 | if ">" in text: |
| 132 | text = text.replace(">", ">") |
| 133 | if "\"" in text: |
| 134 | text = text.replace("\"", """) |
| 135 | return text |
| 136 | except (TypeError, AttributeError): # pragma: no cover |
| 137 | _raise_serialization_error(text) |
| 138 | |
| 139 | |
| 140 | def _serialize_html(write: Callable[[str], None], elem: Element, format: Literal["html", "xhtml"]) -> None: |
no test coverage detected