Convert HTML files to Markdown using pandoc. Use when processing HTML files for text extraction, converting web content to readable markdown, or batch converting HTML files in a course/project directory to markdown format for downstream processing.
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Fix and improve this skill with Tessl
tessl review fix ./skills/html2markdown/SKILL.mdConvert HTML files to clean Markdown using pandoc.
pandoc -f html -t markdown input.html -o output.md# Wrap lines at 80 characters
pandoc -f html -t markdown --wrap=auto --columns=80 input.html -o output.md
# No line wrapping (preserves original flow)
pandoc -f html -t markdown --wrap=none input.html -o output.md
# GitHub-flavored markdown
pandoc -f html -t gfm input.html -o output.mdUse scripts/html2markdown.py for batch conversion:
python scripts/html2markdown.py /path/to/root/directoryOptions:
--output-dir: Specify output directory (default: in-place with .md extension)--flatten: Flatten all output to single directory--wrap: Line wrapping mode (none, auto, preserve)| Format | Flag | Use Case |
|---|---|---|
| GitHub Flavored | -t gfm | Recommended - cleaner output |
| Standard Markdown | -t markdown | Pandoc extensions, may include div syntax |
| CommonMark | -t commonmark | Strict CommonMark |
| Plain text | -t plain | Text only, no formatting |
Note: Standard markdown (-t markdown) may include pandoc-specific syntax like ::: {role="main"} div markers. Use -t gfm for cleaner, more portable output.
Pandoc handles most malformed HTML gracefully. For severely broken HTML, preprocess with:
tidy -q -ashtml input.html | pandoc -f html -t markdown -o output.mdForce UTF-8 encoding:
pandoc -f html -t markdown --metadata encoding=utf-8 input.html -o output.mdPandoc converts everything. To strip scripts/styles before conversion:
from bs4 import BeautifulSoup
with open('input.html', 'r') as f:
soup = BeautifulSoup(f.read(), 'html.parser')
for tag in soup(['script', 'style', 'nav', 'footer', 'header']):
tag.decompose()
clean_html = str(soup)
# Then pass clean_html to pandoc via stdinFor course preprocessing workflows, the batch script outputs files suitable for concatenation into a single *_output.txt file with custom separators.
6d9d92a
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.