(text: str)
| 99 | |
| 100 | |
| 101 | def _escape_attrib_html(text: str) -> str: |
| 102 | # escape attribute value |
| 103 | try: |
| 104 | if "&" in text: |
| 105 | # Only replace & when not part of an entity |
| 106 | text = RE_AMP.sub('&', text) |
| 107 | if "<" in text: |
| 108 | text = text.replace("<", "<") |
| 109 | if ">" in text: |
| 110 | text = text.replace(">", ">") |
| 111 | if "\"" in text: |
| 112 | text = text.replace("\"", """) |
| 113 | return text |
| 114 | except (TypeError, AttributeError): # pragma: no cover |
| 115 | _raise_serialization_error(text) |
| 116 | |
| 117 | |
| 118 | def _serialize_html(write: Callable[[str], None], elem: Element, format: Literal["html", "xhtml"]) -> None: |
no test coverage detected
searching dependent graphs…