Skip to content

fix: strip trailing whitespace from generated vimdoc - #78

Merged
kdheepak merged 1 commit into
kdheepak:mainfrom
geodimm:fix/trailing-whitespace
Sep 17, 2026
Merged

kdheepak merged 1 commit into
kdheepak:mainfrom
geodimm:fix/trailing-whitespace

Conversation

@geodimm

@geodimm geodimm commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Generated vimdoc has trailing whitespace. Code blocks indent their blank lines, lists and definition lists indent them again, and tables pad their cells. Editors and pre-commit hooks that trim whitespace then rewrite the file after every run, so it never matches fresh output (which also defeats #77).

This strips trailing whitespace from the rendered body once, in Writer.Pandoc.

For example, this Markdown:

local a = 1

local b = 2

renders as follows. $ marks the end of each line:

 >lua$
     local a = 1$
-    $
+$
     local b = 2$
 <$
  • An empty line doesn't end a code block in Vim's or Neovim's help syntax, or in Neovim's tree-sitter parser. Neovim's own docs use empty lines inside code blocks.
  • The fix sits in Writer.Pandoc rather than CodeBlock because lists and definition lists skip empty lines, so blank lines in nested code blocks would otherwise disappear.
  • The render tests stripped trailing whitespace before comparing, which hid this; they now compare exact output. A new fixture covers blank lines in code blocks at the top level and in a list.

Code blocks indent every line with four spaces, blank lines included.
Lists and definition lists add their own indentation on top, and tables
pad their cells, so the generated vimdoc has lines ending in whitespace.
Editors, .editorconfig and pre-commit hooks that trim trailing
whitespace then rewrite the file after every generation.

Strip trailing whitespace from the rendered body. Blank lines in code
blocks become empty lines, which do not end a code block in Vim or
Neovim.

The render tests stripped trailing whitespace from the output before
comparing, which hid this. Compare the output exactly instead.
@kdheepak
kdheepak merged commit 3351fd1 into kdheepak:main Sep 17, 2026
3 checks passed
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.

2 participants