Skip to content

Enhancement (config): Add ability for $keepspaces option to strip empty paragraphs - #209

Open
El1as42 wants to merge 1 commit into
theohbrothers:masterfrom
El1as42:enhancement/config-add-ability-for-keepspaces-option-to-strip-empty-paragraphs
Open

El1as42 wants to merge 1 commit into
theohbrothers:masterfrom
El1as42:enhancement/config-add-ability-for-keepspaces-option-to-strip-empty-paragraphs

Conversation

@El1as42

@El1as42 El1as42 commented Oct 13, 2026

Copy link
Copy Markdown

Closes #206

Pandoc converts each empty paragraph of a page to a paragraph containing only a non-breaking space. $keepspaces = 1 (default) removed the non-breaking space, but not the paragraph's blank lines, so each empty paragraph became three blank lines.

Changes

  • $keepspaces = 1: also remove empty paragraphs, i.e. lines containing only non-breaking spaces, including in lists and quotes. Paragraphs are then separated by a single blank line. Lines containing text are not affected, and $keepspaces = 2 still keeps empty paragraphs.
  • The option's description in the script, config.example.ps1, and README.md mentions empty paragraphs.

Since $keepspaces = 1 is the default, this changes the default output. The rendered markdown stays the same, since several blank lines between paragraphs render like one. Only the markdown itself (e.g. in Obsidian's editor) no longer has the extra blank lines.

Tests: the $keepspaces test now includes empty paragraphs between paragraphs, two in a row, in a list, in a quote, and at the end of the page. The existing expectations are unchanged. Unit tests pass on Windows PowerShell 5.1 and PowerShell 7.0. In this repo's CI (run on my fork), all jobs that can currently run pass: Windows PowerShell 5.1 (windows-2022) and PowerShell 7.1 to 7.4. The other jobs currently fail for any PR, before checkout: the windows-2019 runner image was retired, and the PowerShell 6.0 to 7.0 container images are too old for actions/checkout (GLIBC_2.28' not found). Also tested on real notebook pages: each empty paragraph now becomes a single blank line.

🤖 Generated with Claude Code

…mpty paragraphs

Pandoc converts each empty paragraph of a page to a paragraph containing only a non-breaking space. `$keepspaces = 1` removed the non-breaking space, but left the paragraph's blank lines, so each empty paragraph became three blank lines between paragraphs. Empty paragraphs are common, since OneNote's Word export also adds one between separate outlines (text boxes) of a page.

Now `$keepspaces = 1` also removes empty paragraphs, so paragraphs are separated by a single blank line. This includes empty paragraphs in lists and blockquotes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

$keepspaces = 1 leaves three blank lines in place of each empty paragraph

1 participant