🛠️ToolsShed

HTML을 Markdown으로 변환

HTML 코드나 서식 있는 텍스트를 깔끔한 Markdown 문법으로 변환합니다.

자주 묻는 질문

코드 구현

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 two

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.