HTML ke Markdown
Konversi kode HTML atau teks kaya menjadi sintaks Markdown yang bersih.
Pertanyaan yang Sering Diajukan
Implementasi Kode
import html2text
# pip install html2text
html = """
<h1>Hello World</h1>
<p>This is a <strong>bold</strong> paragraph with a
<a href="https://example.com">link</a>.</p>
<ul>
<li>Item one</li>
<li>Item two</li>
</ul>
"""
converter = html2text.HTML2Text()
converter.ignore_links = False # keep hyperlinks
converter.body_width = 0 # no line wrapping
markdown = converter.handle(html)
print(markdown)
# # Hello World
#
# This is a **bold** paragraph with a [link](https://example.com).
#
# * Item one
# * Item twoComments & Feedback
Comments are powered by Giscus. Sign in with GitHub to leave a comment.