Skip to content

Add Copy as Plain Markdown extension#1325

Open
yulonglin wants to merge 2 commits intopilotmoon:masterfrom
yulonglin:add-copy-as-plain-markdown
Open

Add Copy as Plain Markdown extension#1325
yulonglin wants to merge 2 commits intopilotmoon:masterfrom
yulonglin:add-copy-as-plain-markdown

Conversation

@yulonglin
Copy link
Copy Markdown

@yulonglin yulonglin commented Mar 19, 2026

Summary

  • Copies selected rich text as plain Markdown — preserving structure (bullets, blockquotes, code blocks, indentation) while stripping inline formatting (bold, italic, headings, links, images)
  • Uses linkedom + turndown for HTML→Markdown conversion, then regex post-processing to strip formatting markers
  • Code blocks (fenced and inline) are protected from transformation
  • Useful for pasting into plain-text contexts where you want structure but not rich formatting noise

Files

  • contrib/CopyAsPlainMarkdown.popclipext/Config.ts
  • contrib/CopyAsPlainMarkdown.popclipext/README.md

Test plan

  • Manually tested: select rich text in browser/Notion, click action, paste — gets clean structural Markdown
  • Falls back to input.text when no HTML is available
  • bun run check (tsc --noEmit) — passes
  • bunx biome check . — passes

- Copies selected rich text as plain Markdown — structure without formatting

- Strips bold, italic, headings, links, images; preserves bullets, blockquotes, code blocks

- Uses linkedom + turndown for HTML-to-Markdown, then regex to strip inline formatting
- Switch require() to import for module resolution

- Add protectCode/restoreCode to preserve code blocks during simplification

- Handle bold+italic (***text***) before processing separately

- Add type annotations, fix biome formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant