URL to Markdown
Fetches any URL via Chrome CDP and converts HTML to clean markdown, with automatic image downloading.
Script Directory
Important: All scripts are located in the scripts/ subdirectory of this skill.
Agent Execution Instructions:
- Determine this SKILL.md file's directory path as
SKILL_DIR
- Script path =
${SKILL_DIR}/scripts/<script-name>.ts
- Replace all
${SKILL_DIR} in this document with the actual path
Script Reference:
| Script |
Purpose |
scripts/main.ts |
CLI entry point for URL fetching |
scripts/download-images.ts |
Image download and path rewriting |
Preferences (EXTEND.md)
Use Bash to check EXTEND.md existence (priority order):
# Check project-level first
test -f .daftai-skills/daftAI-url-to-markdown/EXTEND.md && echo "project"
# Then user-level
test -f "$HOME/.daftai-skills/daftAI-url-to-markdown/EXTEND.md" && echo "user"
| Path |
Location |
.daftai-skills/daftAI-url-to-markdown/EXTEND.md |
Project directory |
$HOME/.daftai-skills/daftAI-url-to-markdown/EXTEND.md |
User home |
| Result |
Action |
| Found |
Read, parse, apply settings |
| Not found |
Use defaults |
EXTEND.md Supports: Default output directory | Default capture mode | Timeout settings | Image download toggle
Features
- Chrome CDP for full JavaScript rendering
- Two capture modes: auto or wait-for-user
- Automatic image downloading with local path rewriting
<picture> / <source> tag support for complete image extraction
- Clean markdown output with metadata
- Handles login-required pages via wait mode
Usage
# Auto mode (default) - capture and download images
bun ${SKILL_DIR}/scripts/main.ts <url>
# Wait mode - wait for user signal before capture
bun ${SKILL_DIR}/scripts/main.ts <url> --wait
# Skip image downloading
bun ${SKILL_DIR}/scripts/main.ts <url> --no-images
# Save to specific file
bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md
Options
| Option |
Description |
<url> |
URL to fetch |
-o <path> |
Output file path (default: auto-generated) |
--wait |
Wait for user signal before capturing |
--no-images |
Skip downloading images (keep remote URLs) |
--timeout <ms> |
Page load timeout (default: 30000) |
Capture Modes
| Mode |
Behavior |
Use When |
| Auto (default) |
Capture on network idle |
Public pages, static content |
Wait (--wait) |
User signals when ready |
Login-required, lazy loading, paywalls |
Wait mode workflow:
- Run with
--wait → script outputs "Press Enter when ready"
- Ask user to confirm page is ready
- Send newline to stdin to trigger capture
Output Format
YAML front matter with url, title, description, author, published, captured_at fields, followed by converted markdown content.
Output Directory
url-to-markdown/<domain>/
├── <slug>.md
└── images/
├── image1.png
├── image2.svg
└── ...
<slug>: From page title or URL path (kebab-case, 2-6 words)
- Images are saved to
images/ subdirectory next to the markdown file
- Image references in markdown use relative paths:
images/<filename>
- Conflict resolution: Append timestamp
<slug>-YYYYMMDD-HHMMSS.md
Environment Variables
| Variable |
Description |
URL_CHROME_PATH |
Custom Chrome executable path |
URL_DATA_DIR |
Custom data directory |
URL_CHROME_PROFILE_DIR |
Custom Chrome profile directory |
Troubleshooting: Chrome not found → set URL_CHROME_PATH. Timeout → increase --timeout. Complex pages → try --wait mode.
Post-Capture Validation
After the script finishes, the agent MUST perform the following validation steps before reporting completion:
1. Completeness Check
- Use
read_web_page to fetch the original URL
- Compare the generated Markdown against the original page content
- Ensure no paragraphs, sections, or headings are missing
2. Video & Embedded Media Detection
- Search the original page source (
curl) for <video>, <iframe>, <source>, or links to Vimeo, YouTube, Wistia, Lottie, etc.
- For each embedded video found, insert a link at the correct position in the Markdown:
[视频:<caption or description>](<video_url>)
- Videos are often hidden in JS-rendered
mediaGallery blocks — check the page's raw HTML/JSON for vimeo.com, youtube.com, .mp4, .webm
3. Image Placement Verification
- Confirm that images appear after the correct paragraphs, matching their positions on the original page
- Check that all
 references point to files that actually exist in the images/ directory
4. Irrelevant Content Cleanup
- Remove navigation menus, tag/category lists, newsletter signup forms, "Related articles" sections, footer boilerplate, and social media icons
- Remove duplicate titles (e.g., page title repeated as H1)
- Keep only the article body content and author attribution
5. Formatting & Style Verification
- Check that bold/italic emphasis is preserved (not stripped during conversion)
- Verify heading hierarchy (H2/H3 levels match the original page structure)
- Confirm ordered/unordered lists retain their structure
- Ensure blockquotes are properly converted with
>
- Verify code blocks use ``` fencing with correct language tags
- Check that
<hr> elements are converted to ---
- Note: colors, fonts, spacing and other CSS-only styles are out of scope for Markdown
6. Link Verification
- Fix broken links caused by inline cards or embedded previews spanning multiple lines
- Convert relative links (e.g.,
/blog/some-post/) to absolute URLs (e.g., https://domain.com/blog/some-post/)
- Ensure all
[text](url) links are properly formatted
Extension Support
Custom configurations via EXTEND.md. See Preferences section for paths and supported options.
1---2name: daftai-url-to-markdown3description: Fetch any URL and convert to markdown using Chrome CDP, with automatic image downloading. Supports auto-capture and wait-for-user modes. Downloads article images to local directory and rewrites image references to relative paths. Use when user wants to save a webpage as markdown with images. Keywords: url to markdown, save webpage, download article, 网页转markdown4---56# URL to Markdown78Fetches any URL via Chrome CDP and converts HTML to clean markdown, with automatic image downloading.910## Script Directory1112**Important**: All scripts are located in the `scripts/` subdirectory of this skill.1314**Agent Execution Instructions**:151. Determine this SKILL.md file's directory path as `SKILL_DIR`162. Script path = `${SKILL_DIR}/scripts/<script-name>.ts`173. Replace all `${SKILL_DIR}` in this document with the actual path1819**Script Reference**:20| Script | Purpose |21|--------|---------|22| `scripts/main.ts` | CLI entry point for URL fetching |23| `scripts/download-images.ts` | Image download and path rewriting |2425## Preferences (EXTEND.md)2627Use Bash to check EXTEND.md existence (priority order):2829```bash30# Check project-level first31test -f .daftai-skills/daftAI-url-to-markdown/EXTEND.md && echo "project"3233# Then user-level34test -f "$HOME/.daftai-skills/daftAI-url-to-markdown/EXTEND.md" && echo "user"35```3637| Path | Location |38|------|----------|39| `.daftai-skills/daftAI-url-to-markdown/EXTEND.md` | Project directory |40| `$HOME/.daftai-skills/daftAI-url-to-markdown/EXTEND.md` | User home |4142| Result | Action |43|--------|--------|44| Found | Read, parse, apply settings |45| Not found | Use defaults |4647**EXTEND.md Supports**: Default output directory | Default capture mode | Timeout settings | Image download toggle4849## Features5051- Chrome CDP for full JavaScript rendering52- Two capture modes: auto or wait-for-user53- **Automatic image downloading** with local path rewriting54- `<picture>` / `<source>` tag support for complete image extraction55- Clean markdown output with metadata56- Handles login-required pages via wait mode5758## Usage5960```bash61# Auto mode (default) - capture and download images62bun ${SKILL_DIR}/scripts/main.ts <url>6364# Wait mode - wait for user signal before capture65bun ${SKILL_DIR}/scripts/main.ts <url> --wait6667# Skip image downloading68bun ${SKILL_DIR}/scripts/main.ts <url> --no-images6970# Save to specific file71bun ${SKILL_DIR}/scripts/main.ts <url> -o output.md72```7374## Options7576| Option | Description |77|--------|-------------|78| `<url>` | URL to fetch |79| `-o <path>` | Output file path (default: auto-generated) |80| `--wait` | Wait for user signal before capturing |81| `--no-images` | Skip downloading images (keep remote URLs) |82| `--timeout <ms>` | Page load timeout (default: 30000) |8384## Capture Modes8586| Mode | Behavior | Use When |87|------|----------|----------|88| Auto (default) | Capture on network idle | Public pages, static content |89| Wait (`--wait`) | User signals when ready | Login-required, lazy loading, paywalls |9091**Wait mode workflow**:921. Run with `--wait` → script outputs "Press Enter when ready"932. Ask user to confirm page is ready943. Send newline to stdin to trigger capture9596## Output Format9798YAML front matter with `url`, `title`, `description`, `author`, `published`, `captured_at` fields, followed by converted markdown content.99100## Output Directory101102```103url-to-markdown/<domain>/104├── <slug>.md105└── images/106 ├── image1.png107 ├── image2.svg108 └── ...109```110111- `<slug>`: From page title or URL path (kebab-case, 2-6 words)112- Images are saved to `images/` subdirectory next to the markdown file113- Image references in markdown use relative paths: `images/<filename>`114- Conflict resolution: Append timestamp `<slug>-YYYYMMDD-HHMMSS.md`115116## Environment Variables117118| Variable | Description |119|----------|-------------|120| `URL_CHROME_PATH` | Custom Chrome executable path |121| `URL_DATA_DIR` | Custom data directory |122| `URL_CHROME_PROFILE_DIR` | Custom Chrome profile directory |123124**Troubleshooting**: Chrome not found → set `URL_CHROME_PATH`. Timeout → increase `--timeout`. Complex pages → try `--wait` mode.125126## Post-Capture Validation127128After the script finishes, the agent **MUST** perform the following validation steps before reporting completion:129130### 1. Completeness Check131- Use `read_web_page` to fetch the original URL132- Compare the generated Markdown against the original page content133- Ensure no paragraphs, sections, or headings are missing134135### 2. Video & Embedded Media Detection136- Search the original page source (`curl`) for `<video>`, `<iframe>`, `<source>`, or links to Vimeo, YouTube, Wistia, Lottie, etc.137- For each embedded video found, insert a link at the correct position in the Markdown: `[视频:<caption or description>](<video_url>)`138- Videos are often hidden in JS-rendered `mediaGallery` blocks — check the page's raw HTML/JSON for `vimeo.com`, `youtube.com`, `.mp4`, `.webm`139140### 3. Image Placement Verification141- Confirm that images appear after the correct paragraphs, matching their positions on the original page142- Check that all `` references point to files that actually exist in the `images/` directory143144### 4. Irrelevant Content Cleanup145- Remove navigation menus, tag/category lists, newsletter signup forms, "Related articles" sections, footer boilerplate, and social media icons146- Remove duplicate titles (e.g., page title repeated as H1)147- Keep only the article body content and author attribution148149### 5. Formatting & Style Verification150- Check that **bold/italic** emphasis is preserved (not stripped during conversion)151- Verify heading hierarchy (H2/H3 levels match the original page structure)152- Confirm ordered/unordered lists retain their structure153- Ensure blockquotes are properly converted with `>`154- Verify code blocks use ``` fencing with correct language tags155- Check that `<hr>` elements are converted to `---`156- Note: colors, fonts, spacing and other CSS-only styles are out of scope for Markdown157158### 6. Link Verification159- Fix broken links caused by inline cards or embedded previews spanning multiple lines160- Convert relative links (e.g., `/blog/some-post/`) to absolute URLs (e.g., `https://domain.com/blog/some-post/`)161- Ensure all `[text](url)` links are properly formatted162163## Extension Support164165Custom configurations via EXTEND.md. See **Preferences** section for paths and supported options.