Sweeper

pending

by schovi

Cleans up messy markdown with diff preview. Normalizes whitespace, lists, HTML, and more.

β˜… 1 starsUpdated 3mo agoMITDiscovered via Obsidian Unofficial Plugins
View on GitHub

Obsidian Markdown Sweeper

An Obsidian plugin that cleans up messy markdown with a diff preview before applying changes.

Messy markdown Diff preview Cleaned result Settings

Why?

Markdown comes from everywhere - copy-pasted from web pages, exported from Notion, converted from Word docs, or AI-generated content. Each source introduces its own quirks:

  • Smart quotes and curly apostrophes instead of straight ones
  • HTML entities like & and   littered throughout
  • Inconsistent list markers (*, +, -)
  • Broken indentation and excessive whitespace
  • HTML tags mixed with markdown

This plugin normalizes all of it with a single command, showing you exactly what will change before applying.

πŸ’‘ Tip: When pasting from external sources (web, Notion, Word), use Cmd+Shift+V (Mac) or Ctrl+Shift+V (Windows/Linux) to paste as plain text. This avoids most formatting issues before they happen.

See It in Action

Check out the example files to see what Sweeper can do:

  • examples/mess.md - A markdown file with common issues (broken headings, mixed list markers, HTML entities, smart quotes, etc.)
  • examples/sweeped.md - The same file after running Sweeper with aggressive preset

Installation

From Obsidian Community Plugins

  1. Open Settings β†’ Community Plugins
  2. Search for "Sweeper"
  3. Install and enable

Manual Installation

  1. Download main.js, manifest.json, and styles.css from the latest release
  2. Create folder: <vault>/.obsidian/plugins/sweeper/
  3. Copy the files into that folder
  4. Enable in Settings β†’ Community Plugins

Usage

Commands

CommandDescription
Cleanup MarkdownShows diff preview, apply changes with confirmation
Quick CleanupApplies all enabled rules immediately (no preview)
Paste and CleanPastes clipboard content and cleans it in one step

Access via Command Palette (Cmd/Ctrl + P) or the ribbon icon.

Selection Mode

  • No selection: Cleans entire document
  • With selection: Cleans only selected text

Diff Preview

The diff modal shows:

  • Red lines: Content being removed
  • Green lines: Content being added
  • Orange highlight: Whitespace-only changes
  • Visible whitespace markers: Β· for spaces, β†’ for tabs

Presets

Choose how aggressive the cleanup should be:

PresetDescription
MinimalSafe fixes - trailing whitespace, blank lines, EOF newline
StandardCommon normalizations - list markers, heading spaces, tabs
AggressiveFull cleanup - HTML conversion, smart quotes, emphasis style

Presets are cumulative: Standard includes all Minimal rules, Aggressive includes all Standard rules.

You can also switch to Custom mode and toggle individual rules.

Rules

Blank Lines

RulePresetExample
Extra blank linesMinimal3+ blank lines β†’ 1 blank line
Blank line whitespaceMinimalΒ·Β·Β· (empty line) β†’ `` (empty line)
EOF newlineMinimaltext\n\n\n β†’ text\n
Blank lines in listsAggressive- a\n\n- b or 1.\n\n2. β†’ collapsed

Whitespace

RulePresetExample
Invisible charactersMinimalRemoves zero-width chars, converts non-breaking space
Trailing whitespaceMinimaltextΒ·Β· β†’ text
Multiple spacesStandardtooΒ·Β·Β·Β·many β†’ too many
Tabs to spacesStandard→item → ··item
Common indentationAggressiveRemoves leading indent from all lines

Lists

RulePresetExample
Bullet charactersStandardβ€’ β—‹ ● β–Έ β†’ - item
Unicode checkboxesStandard☐ β˜‘ β˜’ β†’ - [ ] / - [x]
List markersStandard* item β†’ - item
CheckboxesStandard- [] task β†’ - [ ] task
Empty list itemsStandard- (empty) β†’ removed
Broken indentationStandardΒ·Β·Β·Β·Β·Β·Β·Β·- item β†’ Β·Β·- item
Ordered list numbersStandard1. 1. 1. β†’ 1. 2. 3.

Formatting

RulePresetExample
Link spacesStandard[text] (url) β†’ [text](url)
Smart quotesAggressive"curly" β†’ "straight"
Emphasis styleAggressive_italic_ β†’ *italic*
Horizontal rulesAggressive*** β†’ ---
Dedupe horizontal rulesAggressive---,---,--- β†’ ---
Code fencesAggressive~~~ β†’ ```

Headings

RulePresetExample
Numbered headersAggressive1 β€” / I β€” / A β€” β†’ ## 1. / ## I. / ## A.
Heading spacesStandard##Title β†’ ## Title
Fix heading level gapsAggressive# H1 β†’ ### H3 becomes ## H3

HTML

RulePresetExample
HTML to MarkdownStandard<b>text</b> β†’ **text** (known tags only)
HTML entitiesStandard&amp; β†’ &, &nbsp; β†’ space (safe entities only)
Aggressive HTML cleanupAggressive&lt;b&gt; β†’ **, strips unknown tags

Note: Standard HTML cleanup preserves &lt;/&gt; entities and unknown HTML tags (they may be intentional). Aggressive mode decodes everything and strips all remaining HTML.

Block Elements

RulePresetExample
Block quotesAggressive>text β†’ > text

Obsidian-specific

RulePresetExample
Tag caseAggressive#Tag β†’ #tag

Settings

  • Clean on save: Clean markdown when you press Cmd/Ctrl+S
    • Off - Disabled
    • Quick - Clean immediately without preview
    • Preview - Show diff modal before saving
  • Clean on paste: Clean plain text pasted from clipboard
    • Off - Disabled
    • Quick - Clean and paste immediately
    • Preview - Show diff with Accept/Keep Original buttons
  • Preset: Choose Minimal, Standard, Aggressive, or Custom
  • Individual rules: Toggle each rule when in Custom mode

Development

npm install          # Install dependencies
npm run dev          # Build in watch mode
npm run build        # Production build
npm run test         # Run tests

License

MIT

For plugin developers

Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.