Paste Reformatter

by Keath Milligan
5
4
3
2
1
Score: 48/100

Description

The Paste Reformatter plugin enhances how content is pasted into Obsidian by giving users precise control over formatting transformations. It intelligently processes both HTML and plain text from the clipboard, cleaning up unwanted elements, adjusting heading structures, and applying customizable regex-based replacements.

Reviews

No reviews yet.

Stats

27
stars
4,458
downloads
5
forks
379
days
88
days
88
days
11
total PRs
1
open PRs
0
closed PRs
10
merged PRs
11
total issues
3
open issues
8
closed issues
0
commits

Latest Version

3 months ago

Changelog

What's Changed

Full Changelog: https://github.com/keathmilligan/obsidian-paste-reformatter/compare/1.4.0...1.4.1

README file from

Github

Paste Reformatter

A plugin for Obsidian that reformats pasted HTML and plain text content, giving you precise control over how content is transformed when pasted into your notes.

  • Use RegEx to transform HTML and Markdown.
  • Reformat HTML before converting to Markdown for better formatting results.
  • Automatically adjust pasted heading levels to match content.
  • Strip blank lines and elements.

Installation

From Obsidian Community Plugins

  1. Open Obsidian and go to Settings
  2. Navigate to Community plugins and disable Safe mode if it's enabled
  3. Click Browse and search for "Paste Reformatter"
  4. Click Install, then Enable to activate the plugin

Manual Installation

  1. Download the latest release from the GitHub releases page
  2. Extract the ZIP file to your Obsidian plugins folder: <vault>/.obsidian/plugins/
  3. Reload Obsidian or restart the app
  4. Go to Settings > Community plugins and enable "Paste Reformatter"

Usage

The Paste Reformatter plugin automatically processes content when you paste it into your notes using Ctrl+V (or Cmd+V on macOS). The plugin:

  1. Detects whether the clipboard contains HTML or plain text
  2. For HTML content:
    • Applies HTML transformations (optionally removing empty elements or hard line breaks, regex string replacement)
    • Converts the HTML to Markdown
  3. For plain text:
    • Treats it as already being in Markdown format
  4. Applies Markdown transformations (heading adjustments, line break handling, regex string replacement)
  5. Inserts the transformed content at the cursor position

A notification will appear briefly indicating whether HTML or plain text content was reformatted. This can be disabled in settings.

Commands

Note: commands are prefixed with "Paste Reformatter:" in the hot-key list.

Command Description
Reformat and Paste By default, Paste Reformatter overrides Obsidian's normal paste behavior. Alternatively, you can disable this behavior (see below) and bind a hot-key to this command.
Paste with Escaped Markdown Pastes text with all markdown escaped. For example, [Data] becomes \[Data].

Potential Conflicts

Paste Reformatter can potentially conflict with other Obsidian plugins that override the default paste behavior. To mitigate this, Paste Reformatter will only prevent the default handling of the paste event if it actually performs a transformation on the pasted text. Otherwise, it will allow the default behavior to take place. This won't prevent all potential collisions, however. So if you run into problems, disable "Override default paste behavior" and bind a hotkey to the "Paste and Reformat" command.

Configuration

alt text

General Settings

Override default paste behavior

When this setting is enabled, the default behavior of Obsidian's Paste function will be enhanced. Otherwise, Reformat and Paste command can be bound to an alternative hot-key to get enhanced paste behavior.

Show paste notifications

When enabled, a notice appears after reformatting content. Disable this to hide notifications.

HTML Transformations

These settings control how HTML content is processed before being converted to Markdown.

Remove Empty Elements

When enabled, this setting removes empty elements (such as empty paragraphs, divs, spans) from the pasted HTML. This helps clean up content that might contain unnecessary structural elements.

Elements with meaningful content (including images, horizontal rules, etc.) are preserved even when empty.

Strip Hard Line Breaks

When enabled, this setting removes <br> tags from the HTML, resulting in paragraph-style text flow. When disabled, line breaks are preserved in the resulting Markdown.

HTML Regex Replacements

This feature allows you to define custom regular expression patterns and replacements to apply to the HTML content before it's converted to Markdown.

Each replacement consists of:

  • Pattern: A regular expression to match in the HTML
  • Replacement: The text to replace the matched pattern with

You can use capture groups in your patterns and reference them in the replacement using $1, $2, etc.

Markdown Transformations

These settings control how the Markdown content is processed after HTML conversion (or directly for plain text).

Max Heading Level

This setting controls the maximum heading level that will be applied to pasted headings.

The value is an integer between 1 and 6, where:

  • H1 (level 1) is treated as disabled (no heading adjustments)
  • H2-H6 (levels 2-6) will enforce that heading level as the minimum

When set to a value other than H1 (disabled), headings that are shallower than the specified level will be increased to that level.

Cascade Heading Levels

When enabled, this option preserves the heading hierarchy by cascading levels based on the Max Heading Level setting.

For example, if Max Heading Level is set to H2:

  • H1 (#) becomes H2 (##)
  • H2 (##) becomes H3 (###)
  • H3 (###) becomes H4 (####)
  • H4 (####) becomes H5 (#####)
  • H5 (#####) becomes H6 (######)
  • H6 (######) remains H6 (######) (capped at H6)

This preserves the relative structure of your headings while ensuring they fit within your document's hierarchy.

This setting is only available when Max Heading Level is set to something other than H1 (disabled).

Contextual Cascade

When enabled, this option adjusts heading levels based on the current context in your document. The plugin detects the heading level at your cursor position and cascades pasted headings relative to that context.

For example, if your cursor is positioned in a section with an H2 heading:

  • Pasted H1 headings will become H3 (one level deeper than the context)
  • Pasted H2 headings will become H4
  • Pasted H3 headings will become H5
  • And so on (capped at H6)

This is particularly useful when pasting content into different sections of your document and wanting the heading structure to fit naturally within the current section's hierarchy.

When used together with Cascade Heading Levels, the relative hierarchy of headings in the pasted content will be preserved.

Remove Empty Lines

When enabled, this setting removes blank lines from the Markdown output, resulting in more compact content. When disabled, empty lines are preserved, maintaining the original spacing.

Markdown Regex Replacements

Similar to HTML Regex Replacements, this feature allows you to define custom regular expression patterns and replacements to apply to the Markdown content after conversion.

This is useful for:

  • Standardizing formatting
  • Removing unwanted patterns
  • Transforming specific content structures
  • Adding custom Obsidian-specific syntax

Examples

Example 1: Cleaning Up Web Content

When copying content from websites, you often get unwanted elements. With these settings:

  • Remove Empty Elements: Enabled
  • Strip Hard Line Breaks: Enabled
  • Max Heading Level: H2
  • Cascade Heading Levels: Enabled

A complex web article with various heading levels and formatting will be transformed into clean, hierarchical Markdown with H2 as the top-level heading.

Example 2: Preserving Document Structure

When copying content from a document with specific formatting:

  • Remove Empty Elements: Disabled
  • Strip Hard Line Breaks: Disabled
  • Max Heading Level: H1 (Disabled)
  • Contextual Cascade: Enabled

The content will maintain its original structure, but headings will be adjusted to fit within the current document's hierarchy based on your cursor position.

HTML Regex Replacement Examples

  1. Remove image width/height attributes
    • Pattern: (<img[^>]*)(width|height)="[^"]*"
    • Replacement: $1
    • Description: Removes width and height attributes from image tags, allowing them to be sized by CSS instead
  2. Convert Google Docs span styles to semantic elements
    • Pattern: <span style="font-weight:\s*bold[^"]*">(.*?)</span>
    • Replacement: <strong>$1</strong>
    • Description: Converts Google Docs styled spans to proper HTML elements
  3. Fix Microsoft Word's special quotes
    • Pattern: (&#8220;|&#8221;)
    • Replacement: "
    • Description: Replaces curly quotes with straight quotes for better compatibility
  4. Remove class attributes
    • Pattern: \s*class="[^"]*"
    • Replacement: ``
    • Description: Strips class attributes that might contain website-specific styling
  5. Convert div tags to paragraphs
    • Pattern: <div([^>]*)>(.*?)</div>
    • Replacement: <p$1>$2</p>
    • Description: Converts div elements to paragraph elements for cleaner Markdown conversion

Markdown Regex Replacement Examples

  1. Add callouts to blockquotes starting with Note:
    • Pattern: > Note:(.*?)(\n\n|\n$)
    • Replacement: > [!note]$1$2
    • Description: Converts simple note blockquotes to Obsidian callouts
  2. Convert URL references to Obsidian wiki links
    • Pattern: \[([^\]]+)\]\(https://en.wikipedia.org/wiki/([^\)]+)\)
    • Replacement: [[$2|$1]]
    • Description: Transforms Wikipedia links to Obsidian wiki links
  3. Add tags to headings with specific keywords
    • Pattern: ^(#+\s*.*?)(TODO|REVIEW|IMPORTANT)(.*)$
    • Replacement: $1$2$3 #task
    • Description: Adds a task tag to headings containing action keywords
  4. Format dates consistently
    • Pattern: (\d{1,2})/(\d{1,2})/(\d{4})
    • Replacement: $3-$1-$2
    • Description: Converts MM/DD/YYYY dates to YYYY-MM-DD format
  5. Convert asterisk lists to dash lists
    • Pattern: ^(\s*)\*
    • Replacement: $1-
    • Description: Standardizes list formatting to use dashes instead of asterisks

License

This project is licensed under the BSD Zero Clause License - see the LICENSE file for details.

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Advanced Tables
6 years ago by Tony Grosinger
Improved table navigation, formatting, and manipulation in Obsidian.md
Admonition
5 years ago by Jeremy Valentine
Adds admonition block-styled content to Obsidian.md
Paste URL into selection
6 years ago by Denis Olehov
Paste URLs into selected text "notion style"
cMenu
5 years ago by Chetachi
An Obsidian.md plugin that adds a minimal text editor modal for a smoother writing/editing experience ✍🏽.
Smart Typography
5 years ago by mgmeyers
Converts quotes to curly quotes, dashes to em dashes, and periods to ellipses
Markdown Formatting Assistant
5 years ago by Reocin
This Plugin provides a simple WYSIWYG Editor for Markdown and in addition a command line interface. The command line interface facilitate a faster workflow.
Table Extended
5 years ago by AidenLx
Extend basic table in Obsidian with MultiMarkdown table syntax
Text expand
6 years ago by MrJackphil
A simple text expand plugin for Obsidian.md
Heading Level Indent
3 years ago by svonjoi
obsidian plugin for hierarchical structuration of document content based on heading levels
Change Case
3 years ago by David Brockman
Plugin to let you change the case (camelCase, snake_case, etc) of the current selection.
Paste Mode
5 years ago by Jacob Levernier
Obsidian Notes plugin for pasting text and blockquotes to the cursor's current level of indentation.
Paste Link
2 years ago by Jose Elias Alvarez
Intelligently paste Markdown links in Obsidian.
SupSub
3 years ago by Wjgoarxiv
::SupSub enables wrapping selected text with `<sup>` or `<sub>` tags::
Paste As Html
3 years ago by maotong06
Code block from selection
5 years ago by Dmitry Savosh
Obsidian plugin. Adds code block for the selected text.
Callout Integrator
3 years ago by
A plugin for Obsidian to allow the integration of long blocks of text into callouts.
Wrap with shortcuts
4 years ago by Manic Chuang
Wrap selected text in custom tags with shortcuts.
Auto pair chinese symbol
5 years ago by renmu123
中文符号自动补齐
Inline spoilers
2 years ago by logonoff
Adds Discord-like syntax for inline spoilers.
Ordered List Style
4 years ago by erykwalder
Writing
3 years ago by johackim
Write and format your next book directly from Obsidian
Multi-line Formatting
5 years ago by nmady
Format Obsidian text over an entire selection, even if that selection has paragraph breaks in the middle!
Extended Markdown Syntax
a year ago by Kotaindah55
Extend your Markdown syntax using delimiters instead of HTML tags, such as underlining, superscript, subscript, highlighting, and spoiler.
Format Hotkeys
5 years ago by Ansel Santosa
Google Docs style formatting hotkeys for Obsidian
Remove Newlines
2 years ago by Elias Jaffe
A plugin for Obsidian.md which removes newlines and blank lines from selected or pasted text.
Formatto
2 years ago by Deca
Simple, fast, and easy-to-use Obsidian Markdown formatter.
Autocorrect Formatter
2 years ago by b-yp
A plugin running on Obsidian that utilizes autocorrect to format Markdown content.
Toggle Case
3 years ago by automattech
Obsidian plugin to toggle between `lowercase` `UPPERCASE` and `Title Case`
ObsidianTweaks
4 years ago by Jeppe Klitgaard
A plugin that implements a number of tweaks that should've been native to Obsidian.
Kindle Highlights Importer
2 years ago by MovingMillennial
Interlinear Glossing
3 years ago by Mijyuoon
An Obsidian plugin for interlinear glosses used in linguistics texts.
Blockquote Levels
4 years ago by Carlo Zottmann
A plugin for Obsidian (https://obsidian.md) that adds commands for increasing/decreasing the blockquote level of the current line or selection(s).
LaTeX to unicode converter
3 years ago by fjdu
Convert LaTeX commands into unicode sequences
Callout Toggles
2 years ago by Aly Thobani
An Obsidian plugin to quickly add, change, or remove callout wrappers in your notes.
Auto-\displaystyle Inline Math
2 years ago by Ryota Ushio
An Obsidian.md plugin to automatically make all inline maths \displaystyle.
Text Conversions
3 years ago by Juan D Frias
Text conversions for Obsidian
heti
2 years ago by Moeyua
Canvas Format Brush
a year ago by wenlzhang
An Obsidian plugin that allows you to copy and paste formatting attributes (size and color) between canvas elements, similar to the format painter in Word.
Image Size
a year ago by Jie Zhang
Set the default size for pasted images.
Paste From History
2 years ago by Daniel Karakka
Obsidian plugin that adds the ability to paste text from Obsidian's clipboard history.
Jisage -Japanese Indentation-
2 years ago by Telehakke
Obsidian plugin.
Line Commands
2 years ago by charliecm
Adds commands to quickly select, copy, cut, and paste lines under the selection or cursor.
复制图文 (Copy Image Text)
2 years ago by msgk
obsidian插件,复制笔记内容(包括文本和图片)到剪贴板
Image Helper
2 years ago by Chongmyung Park
Context menu to convert a image to another format in reading view in Obsidian.md
Paste transform
2 years ago by Timofey Koolin
Better Order List
2 years ago by Boninall
Discord Timestamps
a year ago by Erika Gozar
Displays discord timestamps in read mode as they would appear in Discord.
Image to HTML
a year ago by 0x1DA9430
A plugin for Obsidian that converts pasted images to HTML format instead of Obsidian's wikilink or Markdown format
Heading Toggler
2 years ago by Lord Turmoil
Toggle heading levels in Obsidian
Chat clips
a year ago by sleepingraven
Record chat in ordinary markdown list.
Keyboard Formatter
8 months ago by Lauloque
Formats keyboard text (kbd) in your Obsidian notes quickly and consistently.
Vim Marker Sharpener
a year ago by Artem Dvoryadkin
Text formatting commands in Vim mode. Supports applying styles (bold, italic, etc.). Works correctly in visual mode with selected text.
Paste as Embed
2 years ago by Matt Laporte
Obsidian plugin to paste contents of clipboard into a new note, and embed it in the active note.
Paste as file link
8 months ago by Matthias Büge
This plugin is used to paste a text from the clipboard as a link to an existing obsidian note
Note Placeholder
a year ago by XZSt4nce
Replaces text of note link to placeholder in view mode.
Bottom to Top
a year ago by Henry Gustafson