mirror of
https://github.com/keathmilligan/obsidian-paste-reformatter.git
synced 2026-07-22 05:43:44 +00:00
- Add isCursorInCodeBlock() helper that detects fenced code blocks by scanning from line 0 to cursor, toggling on backtick/tilde fences - Add early-return guard in onPaste() to bypass reformatting when cursor is inside a code block - Archive openspec change proposal and update paste-interception spec with new requirement
789 B
789 B
Change: Skip reformatting when pasting into a code block
Why
When a user pastes content into a fenced code block (```), the plugin reformats the pasted text (HTML-to-Markdown conversion, heading cascade, regex replacements, etc.). This destroys the raw content the user intended to paste as code. The plugin should detect code block context and let Obsidian's default paste proceed. (GitHub issue #14)
What Changes
- Add a code block detection function that scans backward from the cursor to determine if the cursor is inside a fenced code block
- Add an early-return guard in
onPaste()that skips reformatting when the cursor is inside a code block
Impact
- Affected specs:
paste-interception - Affected code:
src/main.ts(onPastemethod, new helper function)