Convert HTML content to clean Markdown.
(self, html: str)
| 157 | return "_shared", "shared" |
| 158 | |
| 159 | def html_to_markdown(self, html: str) -> str: |
| 160 | """Convert HTML content to clean Markdown.""" |
| 161 | if not html: |
| 162 | return "" |
| 163 | md = self.h2t.handle(html) |
| 164 | md = re.sub(r"\n{3,}", "\n\n", md) |
| 165 | md = re.sub(r"\[/?[a-z_]+[^\]]*\]", "", md) |
| 166 | md = md.replace("…", "...").replace("&", "&") |
| 167 | md = md.replace("–", "-").replace("—", "--") |
| 168 | md = md.replace("&", "&").replace(" ", " ") |
| 169 | return md.strip() |
| 170 | |
| 171 | def clean_title(self, title_raw: str) -> str: |
| 172 | """Clean HTML entities from title.""" |