Skip to content

fix: conceal padding spaces in multi-backtick code spans per CommonMark spec#635

Merged
MeanderingProgrammer merged 1 commit into
MeanderingProgrammer:mainfrom
0x1b2c:main
Apr 12, 2026
Merged

fix: conceal padding spaces in multi-backtick code spans per CommonMark spec#635
MeanderingProgrammer merged 1 commit into
MeanderingProgrammer:mainfrom
0x1b2c:main

Conversation

@0x1b2c
Copy link
Copy Markdown
Contributor

@0x1b2c 0x1b2c commented Apr 12, 2026

CommonMark specifies that when a code span uses multiple backtick delimiters, a single leading and trailing space is stripped from the content, provided the content is not entirely whitespace. This is the standard way to include literal backticks in inline code.

For example, to render Cmd+` as inline code, one writes:

`` Cmd+` ``

The double backticks are delimiters, and the spaces adjacent to them are padding that should not appear in the rendered output.

Previously, render-markdown.nvim correctly concealed the backtick delimiters but left the padding spaces visible, resulting in extra whitespace in the rendered output.

This adds a conceal_padding step to the inline code renderer that detects multi-backtick code spans and conceals the inner padding spaces, matching the expected CommonMark rendering.

Reference: https://spec.commonmark.org/0.31.2/#code-spans (examples 349-362)

…rk spec

CommonMark specifies that when a code span uses multiple backtick
delimiters, a single leading and trailing space is stripped from the
content, provided the content is not entirely whitespace. This is the
standard way to include literal backticks in inline code.

For example, to render Cmd+` as inline code, one writes:

    `` Cmd+` ``

The double backticks are delimiters, and the spaces adjacent to them
are padding that should not appear in the rendered output.

Previously, render-markdown.nvim correctly concealed the backtick
delimiters but left the padding spaces visible, resulting in extra
whitespace in the rendered output.

This adds a conceal_padding step to the inline code renderer that
detects multi-backtick code spans and conceals the inner padding spaces,
matching the expected CommonMark rendering.

Reference: https://spec.commonmark.org/0.31.2/#code-spans (examples 349-362)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MeanderingProgrammer
Copy link
Copy Markdown
Owner

Thank you!

@MeanderingProgrammer MeanderingProgrammer merged commit f128369 into MeanderingProgrammer:main Apr 12, 2026
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