Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Post text, images, videos, and long-form articles to X (Twitter) via real Chrome browser automation.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/articles.md
1# X Articles - Detailed Guide23Publish Markdown articles to X Articles editor with rich text formatting and images.45## Prerequisites67- X Premium subscription (required for Articles)8- Google Chrome installed9- `bun` installed1011## Usage1213```bash14# Publish markdown article (preview mode)15${BUN_X} {baseDir}/scripts/x-article.ts article.md1617# With custom cover image18${BUN_X} {baseDir}/scripts/x-article.ts article.md --cover ./cover.jpg1920# Actually publish21${BUN_X} {baseDir}/scripts/x-article.ts article.md --submit22```2324## Markdown Format2526```markdown27---28title: My Article Title29cover_image: /path/to/cover.jpg30---3132# Title (becomes article title)3334Regular paragraph text with **bold** and *italic*.3536## Section Header3738More content here.39404142- List item 143- List item 244451. Numbered item462. Another item4748> Blockquote text4950[Link text](https://example.com)5152\`\`\`53Code blocks become blockquotes (X doesn't support code)54\`\`\`55```5657## Frontmatter Fields5859| Field | Description |60|-------|-------------|61| `title` | Article title (or uses first H1) |62| `cover_image` | Cover image path or URL |63| `cover` | Alias for cover_image |64| `image` | Alias for cover_image |6566## Image Handling67681. **Cover Image**: First image or `cover_image` from frontmatter692. **Remote Images**: Automatically downloaded to temp directory703. **Placeholders**: Images in content use `XIMGPH_N` format714. **Insertion**: Placeholders are found, selected, and replaced with actual images7273## Markdown to HTML Script7475Convert markdown and inspect structure:7677```bash78# Get JSON with all metadata79${BUN_X} {baseDir}/scripts/md-to-html.ts article.md8081# Output HTML only82${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --html-only8384# Save HTML to file85${BUN_X} {baseDir}/scripts/md-to-html.ts article.md --save-html /tmp/article.html86```8788JSON output:89```json90{91"title": "Article Title",92"coverImage": "/path/to/cover.jpg",93"contentImages": [94{95"placeholder": "XIMGPH_1",96"localPath": "/tmp/x-article-images/img.png",97"blockIndex": 598}99],100"html": "<p>Content...</p>",101"totalBlocks": 20102}103```104105## Supported Formatting106107| Markdown | HTML Output |108|----------|-------------|109| `# H1` | Title only (not in body) |110| `## H2` - `###### H6` | `<h2>` |111| `**bold**` | `<strong>` |112| `*italic*` | `<em>` |113| `[text](url)` | `<a href>` |114| `> quote` | `<blockquote>` |115| `` `code` `` | `<code>` |116| ```` ``` ```` | `<blockquote>` (X limitation) |117| `- item` | `<ul><li>` |118| `1. item` | `<ol><li>` |119| `` | Image placeholder |120121## Workflow1221231. **Parse Markdown**: Extract title, cover, content images, generate HTML1242. **Launch Chrome**: Real browser with CDP, persistent login1253. **Navigate**: Open `x.com/compose/articles`1264. **Create Article**: Click create button if on list page1275. **Upload Cover**: Use file input for cover image1286. **Fill Title**: Type title into title field1297. **Paste Content**: Copy HTML to clipboard, paste into editor1308. **Insert Images**: For each placeholder (reverse order):131- Find placeholder text in editor132- Select the placeholder133- Copy image to clipboard134- Paste to replace selection1359. **Post-Composition Check** (automatic):136- Scan editor for remaining `XIMGPH_` placeholders137- Compare expected vs actual image count138- Warn if issues found13910. **Review**: Browser stays open for 60s preview14011. **Publish**: Only with `--submit` flag141142## Example Session143144```145User: /post-to-x article ./blog/my-post.md --cover ./thumbnail.png146147Claude:1481. Parses markdown: title="My Post", 3 content images1492. Launches Chrome with CDP1503. Navigates to x.com/compose/articles1514. Clicks create button1525. Uploads thumbnail.png as cover1536. Fills title "My Post"1547. Pastes HTML content1558. Inserts 3 images at placeholder positions1569. Reports: "Article composed. Review and use --submit to publish."157```158159## Troubleshooting160161- **No create button**: Ensure X Premium subscription is active162- **Cover upload fails**: Check file path and format (PNG, JPEG)163- **Images not inserting**: Verify placeholders exist in pasted content164- **Content not pasting**: Check HTML clipboard: `${BUN_X} {baseDir}/scripts/copy-to-clipboard.ts html --file /tmp/test.html`165166## How It Works1671681. `md-to-html.ts` converts Markdown to HTML:169- Extracts frontmatter (title, cover)170- Converts markdown to HTML171- Replaces images with unique placeholders172- Downloads remote images locally173- Returns structured JSON1741752. `x-article.ts` publishes via CDP:176- Launches real Chrome (bypasses detection)177- Uses persistent profile (saved login)178- Navigates and fills editor via DOM manipulation179- Pastes HTML from system clipboard180- Finds/selects/replaces each image placeholder181