Fix: Markdown preview renders hanging indents as code blocks #3217
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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