Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Markdown preview renders hanging indents as code blocks #3217

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from

Conversation

codebykat
Copy link
Member

Fix

A tab (four spaces) at the beginning of a paragraph is parsed as a code block. This is an issue that other Markdown text editors have encountered (Obsidian, for example, has many complaints, e.g. #).

Naturally showdown does not have an option to disable these style codeblocks, despite the fact that we also have Github-style "code fence" support (three backticks). As others have done, I experimented with a naive regex replace that removes four spaces at the beginning of a line and uses three instead, but there are a lot of edge cases with list indentation that probably aren't handled. I also experimented with adjusting the editor's options around tab sizes, but due to the auto detect (and the fact that we're probably going to get four-space-indentations from clients or from existing saved notes) this seems like a nonstarter.

I think if we cleaned up this regex to catch more of the edge cases, it might be a good idea to add this.

Test

Release

Don't render indented paragraphs as code blocks

@codebykat codebykat self-assigned this Jun 13, 2024
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.

1 participant