Copy As PlainText

by Finickyspider
5
4
3
2
1
Score: 32/100

Description

The Copy As PlainText plugin adds a one-click way to convert your markdown content into clean, unformatted text. Whether you're stripping headings, links, tables, math blocks, or footnotes, this plugin gives you fine-grained control over what gets removed. It offers two modes: a quick regex-based Simple Mode for basic formatting, and a slower but more accurate AST-based mode that parses full GitHub-flavored markdown. You can toggle individual syntax elements like hashtags, LaTeX, YAML frontmatter, or highlight markers in the settings. Access is quick via right-click or the command palette, making it ideal for copying notes into emails, documents, or plain-text apps without markdown clutter.

Reviews

No reviews yet.

Stats

5
stars
1,680
downloads
0
forks
199
days
23
days
109
days
3
total PRs
0
open PRs
0
closed PRs
3
merged PRs
2
total issues
2
open issues
0
closed issues
9
commits

Latest Version

4 months ago

Changelog

Copy As PlainText - Changelog v1.0.3

New Features (FR-1: Obsidian-Specific Markup Stripping)

Convert Obsidian wiki-style internal links to plain text while preserving meaningful content.

Behavior:

  • [[Page]]Page
  • [[Page|Alias]]Alias (with default settings)
  • [[Folder/Sub/Page]]Folder/Sub/Page (paths preserved by default)

New Settings:

  • Strip internal links (toggle, default: ON)

    • Enables/disables internal link stripping
  • Internal link mode (dropdown, default: "Prefer alias, else target")

    • Prefer alias, else target: Uses alias if present, otherwise shows target
    • Always use target (ignore alias): Ignores alias, always shows the link target
  • Strip paths to basename (toggle, default: OFF)

    • When enabled: [[Folder/Sub/Page]]Page
    • When disabled: [[Folder/Sub/Page]]Folder/Sub/Page
  • Heading/block part handling (dropdown, default: "Keep full reference")

    • Keep full reference: Preserves [[Page#Heading]] and [[Page^blockid]] as-is
    • Strip to page name only: [[Page#Heading]]Page
    • Use heading/block part only: [[Page#Heading]]Heading

Feature 2: Strip Block IDs ^blockid

Remove Obsidian block reference markers from end-of-line positions, while safely preserving caret characters used in math expressions.

Behavior:

  • Some text here ^block-id-1Some text here
  • x^2 + y^2 = z^2x^2 + y^2 = z^2 (mid-line carets preserved)
  • Content with trailing spaces ^blockid Content with trailing spaces

New Settings:

  • Strip block IDs (toggle, default: ON)

    • Enables/disables block ID stripping
  • Block ID stripping mode (dropdown, default: "End of line only (safe)")

    • End of line only (safe): Only strips block IDs at end of line (default, prevents false positives)
    • Anywhere in line (advanced): Strips block IDs anywhere in line (riskier, may catch mid-line text)

Feature 3: Strip Embeds ![[...]]

Handle Obsidian embed syntax for notes, images, and other media files.

Behavior (with "Remove entirely" mode):

  • ![[Embedded Note]] → (removed)
  • Text before ![[embed]] afterText before after
  • ![[Image.png|Caption]] → (removed)

New Settings:

  • Handle embeds (toggle, default: ON)

    • Enables/disables embed processing
  • Embed handling mode (dropdown, default: "Remove entirely")

    • Remove entirely: Deletes embed markup completely
    • Replace with placeholder: Replaces with [embedded: Note] format
    • Convert to link-text equivalent: Treats like a stripped link (shows alias if present, else filename)

Feature 4: Non-Markdown File Targets

Smart handling of links and embeds pointing to non-markdown files (PDFs, images, audio, video, documents, archives, data files, web files).

Supported Extensions:

  • Documents: .doc, .docx, .xls, .xlsx, .ppt, .pptx
  • Images: .jpg, .jpeg, .png, .gif, .svg, .webp, .bmp, .ico
  • Media: .mp3, .wav, .ogg, .mp4, .webm, .mov, .avi, .mkv
  • Archives: .zip, .rar, .7z, .tar, .gz
  • Data: .csv, .json, .xml, .yaml
  • Web: .html, .css, .js, .ts
  • And more: .pdf, .pdf

Behavior (with default settings):

  • [[report.pdf]]report.pdf
  • [[report.pdf|Q4 Report]]Q4 Report
  • [[assets/files/document.pdf]]assets/files/document.pdf
  • ![[photo.jpg]] → (removed, as per embed mode)

New Settings:

  • Handle non-markdown targets (toggle, default: ON)

    • Enables/disables special handling for non-markdown file references
  • Non-markdown target mode (dropdown, default: "Alias if present, else filename")

    • Alias if present, else filename: Uses alias if available, otherwise shows filename
    • Always use filename: Always outputs just the filename, ignores alias
    • Remove entirely: Deletes non-markdown file references completely
    • Use placeholder: Replaces with [file: filename] format

UI/UX Improvements

Conditional Settings Display

  • Advanced Unified Pipeline Settings now only display when "Super Simple mode" is disabled
  • When "Super Simple mode" is enabled, only the Obsidian-specific settings are visible
  • This prevents user confusion by hiding settings that don't apply to the current mode

Settings Organization

  • New section: "Obsidian-Specific Stripping" with visual hierarchy
  • Sub-settings are indented with a left border for better visual grouping
  • Each main toggle can reveal/hide related sub-settings when clicked

Styling

  • Added CSS class .setting-indent for visual indentation of sub-settings
  • Left border indicator shows settings are grouped together

Super Simple Mode: ON

Super Simple Mode: OFF


Technical Details

Processing Order (Critical)

For correct regex operation, Obsidian-specific stripping applies in this order:

  1. Embeds first (![[...]]) - Must run before internal links to avoid conflicts
  2. Internal links ([[...]]) - After embeds are handled
  3. Block IDs (^blockid) - Independent, end-of-line focused

This order is maintained in both Super Simple mode and Unified Pipeline mode.

Unified Pipeline Fix

  • Fixed execution order: Obsidian stripping now runs BEFORE the unified markdown pipeline
  • This prevents the remark parser from interfering with Obsidian syntax detection
  • Ensures wiki links and embeds are stripped cleanly before other markdown processing

Regex Patterns

  • Internal links: \[\[([^\]|]+)(?:\|([^\]]+))?\]\]

    • Safely matches: [[target]] and [[target|alias]]
    • Does not match after embeds are already removed
  • Embeds: !\[\[([^\]|]+)(?:\|([^\]]+))?\]\]

    • Safely matches: ![[target]] and ![[target|alias]]
    • Must run first to prevent conflicts with link pattern
  • Block IDs (EOL): \s+\^[A-Za-z0-9-]+\s*$ (multiline mode)

    • Only matches when preceded and followed by whitespace at line end
    • Prevents false positives with math expressions like 2^3 or x^2
  • Non-MD file detection: Comprehensive regex for 20+ file extensions

    • Case-insensitive matching
    • Fast lookup using .test() method

Default Settings Summary

Setting Default Mode(s)
Strip internal links ON All
Internal link mode Prefer alias, else target All
Strip paths to basename OFF All
Heading/block part handling Keep full reference All
Strip block IDs ON All
Block ID stripping mode End of line only (safe) All
Handle embeds ON All
Embed handling mode Remove entirely All
Handle non-markdown targets ON All
Non-markdown target mode Alias if present, else filename All

Backward Compatibility

Fully backward compatible

  • All new settings default to enabled with sensible options
  • Existing users will immediately benefit from Obsidian-specific stripping
  • No breaking changes to existing functionality
  • Can be disabled per-feature via settings

Test Coverage

Comprehensive torture test included covering:

  • Basic internal links with and without aliases
  • Paths and nested folder structures
  • Heading and block references
  • End-of-line block IDs
  • Embeds with various media types
  • Non-markdown file targets
  • Edge cases and special characters
  • False positive prevention (math expressions, code blocks)
  • Whitespace variations
  • All supported file extensions

Test Result: 99/100 - Some minor edge cases like [[Note|]] and [[]] still not handled - but these are invalid Obsidian syntax that users will rarely encounter. I'll fix this in the next pass.

README file from

Github

Copy As PlainText

Clean, one-click plain-text copy from Obsidian!

GitHub release (latest by date) Downloads GitHub stars

[!IMPORTANT] If you want to use any advanced/fine-tuning settings, make sure to disable Simple Mode in the plugin options. If Simple Mode is on, all advanced options are ignored.

What It Does

  • Adds a “Copy as Plain-Text” command to:
    • The editor’s right-click context menu
    • The Command Palette
  • Offers two stripping modes:
    1. Super Simple (regex-based) — strips common markers like #, **bold**, *italic*, `code`, [links](url), ![images](https://raw.githubusercontent.com/FinickySpider/Obsidian-Copy-as-Plaintext/HEAD/url)
    2. Unified/Remark (AST-based) — full GFM support (tables, task lists, footnotes, math, frontmatter, HTML blocks)
  • Fine-tunable settings let you enable/disable:
    • GFM tables & task lists
    • YAML frontmatter
    • Inline and block math
    • Footnotes & inline refs
    • Highlight markers (==text==)
    • Custom markers ([~], [>])
    • List numbers (1., 2., …)
    • Dashes wrapping words (---word---)
    • Hashtags (#tag) and mentions (@user)
    • LaTeX commands (\quad, \int, etc.)

Features

  • Strip basic Markdown: headings, emphasis, links, images, inline code
  • Unified AST processing for robust handling of tables, footnotes, math, HTML blocks
  • Super Simple mode for minimal regex stripping, ideal for quick, predictable plain-text
  • Context menu integration for one-click copying
  • Command Palette entry for keyboard-driven workflow
  • Customizable: toggle each stripping step on or off in plugin settings

Installation

Community

  • Search for 'Copy As PlainText' in Obsidian’s Community Plugins browser.

Manual

  1. Download the latest ZIP from the Releases page
  2. Extract into your vault’s plugin folder:
    'YourVault/.obsidian/plugins/'
  3. Open Obsidian → Settings → Community Plugins → Reload or toggle “Copy As PlainText” on.

Usage

  1. Select the text in any Markdown note.
  2. Right-click → Copy as Plain-Text, or open the Command Palette (Ctrl/Cmd+P) → Copy as Plain-Text.
  3. Paste anywhere, your selected text will be stripped of Markdown formatting.
  4. Optionally, open Settings → Plugin Options to tweak which syntax elements to strip or preserve.

Screenshots

Settings Panel

Context Menu


Known Issues & Quirks

  • Performance: AST-based stripping can be slower on very large selections—use Super Simple mode for speed.
  • Edge-case syntax: Some niche Markdown plugins or custom syntax may not be recognized by the AST pipeline.
  • Backslash escapes: By default, backslash-escaped characters (e.g. *, [ ) are unescaped; toggle settings if you need to preserve literal backslashes.
  • Table layout: The AST pipeline removes table structure; if you need plain rows or pipes, consider disabling table stripping in settings.

FAQ

Q: Why don’t my settings seem to do anything?
A: Make sure Simple Mode is turned off in the plugin settings, otherwise, advanced options are ignored.

Q: Can I copy images as plain text?
A: Yes. Markdown image links are stripped down to the alt/title text.

Q: Does it handle custom Markdown plugins?
A: The AST-based mode covers most standard Markdown. Some third-party plugin syntax might not be recognized. Though during my torture tests it covered most things. Let me know if you have requests for specific plugin stripping Here

Q: What’s the difference between Simple Mode and Unified/Remark?
A: Simple Mode is a fast, lightweight text-only method that strips Markdown using simple rules (think regex). It’s quick and works well for basic notes, but can make mistakes with complex formatting (code blocks, nested styling, HTML, tables, etc.). Unified/Remark parses the Markdown properly and removes formatting reliably. It’s slower, but the results are more accurate.


Support & Feedback

I'd love to hear from you, if you have feature requests, issues, questions, or just want to talk about it! I'm always happy to help tweak things or create niche features is needed.


License

BSD 0-Clause license


Built with ❤️ for Obsidian users who just want clean, copy-ready text.


If this script helped you, you can support it here:

Thanks for visiting ☕