Automattic / simplenote-electron

Simplenote for Web, Windows, and Linux
https://app.simplenote.com
GNU General Public License v2.0
4.69k stars 553 forks source link

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

Open codebykat opened 3 weeks ago

codebykat commented 3 weeks ago

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

1. 2. 3.

Release

Don't render indented paragraphs as code blocks