Copy As PlainText

by Finickyspider
favorite
share
0.0
(0)
5
4
3
2
1
Score: 31/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
4
stars
772
downloads
0
forks
93
days
4
days
4
days
3
total PRs
0
open PRs
0
closed PRs
3
merged PRs
1
total issues
1
open issues
0
closed issues
9
commits
Latest Version
4 days 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 ^blockidContent 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

Image

Super Simple Mode: OFF

Image


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