Url to markdown
WebページのURLをhtml2text経由でMarkdown形式のテキストに変換するスキル。html2text CLIはURLを直接受け付けずファイルパスとして解釈してしまうため、事前にHTTPで取得してから変換する。 ユーザーがURLを渡して「Markdown化して」「テキストで見たい」「html2textで変換して」「内容を確認したい」と言ったときは、明示されていなくてもこのスキルを参照すること。From its SKILL.md
npx -y skills add idylle-cynique/solo-dev-skills --skill url-to-markdownAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 27 days oldThe repository was created 27 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
3.6 KB, ~1.1k tokens by cl100k_base, as published. Nobody here has run it
前提: なぜこのスキルが必要か
html2text CLIは filename 位置引数のみを受け付け、URLを渡すと FileNotFoundError になる。そのため、URLをMarkdown化するには「HTTPで取得 → html2textに渡す」という2段階の処理が必要であり、それを1コマンドにまとめたものがこのスキル。
依存関係の確認
-
html2textがインストール済みか確認する。python3 -c "import html2text; print(html2text.__version__)" -
未インストール、または
ModuleNotFoundErrorの場合はpip install html2textの実行可否をユーザーに確認してからインストールする(環境変更を伴うため無断で実行しない)。 -
プロジェクトに
venvが存在する場合は、インストール・実行の前にsource venv/bin/activateで有効化する。
実行手順
-
対象URLを引数に、変換スクリプトを実行する。デフォルトで本文抽出が有効。
python3 ${CLAUDE_SKILL_DIR}/resources/scripts/url_to_markdown.py "<URL>" -
本文抽出をせずページ全体を変換したい場合は
--fullを付ける。python3 ${CLAUDE_SKILL_DIR}/resources/scripts/url_to_markdown.py "<URL>" --full -
標準出力に変換後のMarkdownが表示される。そのままユーザーへ提示するか、ユーザーの指示に応じてファイルへ保存する。
本文抽出のロジック
技術記事・公式ドキュメントであっても <article> タグが必ず使われているとは限らない(<main> や独自クラスの div で本文を囲むサイトも多い)ため、以下の優先順位でフォールバックする。追加の依存パッケージ(BeautifulSoup等)は増やさず、標準ライブラリの re のみで実装している。
<article>タグがあれば、その内容を使う- なければ
<main>タグを試す - それもなければ
class/idにcontent/post/article/entryを含むdivを探す - いずれも見つからなければページ全体(
--fullと同じ結果)を使う
出力時の注意点
- 本文抽出のフォールバックはヒューリスティックであり、必ず正確に本文だけを抜き出せるとは限らない。抽出結果が不自然(短すぎる・本文が欠けている等)な場合は
--fullで全体を確認する - JavaScriptでクライアントサイドレンダリングされるSPA形式のドキュメントサイト(Docusaurus、GitBook等)は、
urllibでの取得では本文がそもそもHTMLに含まれない場合がある。この場合は本文抽出の優先順位以前の問題であり、ヘッドレスブラウザでのレンダリングが必要になる旨をユーザーに伝える - それでもノイズが残る場合は
html2text.HTML2Text()のオプション(ignore_images/ignore_links等)で情報量を減らす選択肢もある
出力例
examples/sample.md を参照。
What ships with it: 2 files
3.9 KB alongside SKILL.md, 1 of them executable
examples/
- sample.md1.5 KB
resources/
- scripts/url_to_markdown.pyruns2.4 KB