Escape character data.
(text: str)
| 139 | |
| 140 | |
| 141 | def escape_cdata(text: str) -> str: |
| 142 | """ Escape character data. """ |
| 143 | if "&" in text: |
| 144 | # Only replace & when not part of an entity |
| 145 | text = RE_AMP.sub('&', text) |
| 146 | if "<" in text: |
| 147 | text = text.replace("<", "<") |
| 148 | if ">" in text: |
| 149 | text = text.replace(">", ">") |
| 150 | return text |
| 151 | |
| 152 | |
| 153 | def run_postprocessors(text: str, md: Markdown) -> str: |