silverbulletmd / silverbullet

The knowledge hacker's notebook
https://silverbullet.md
MIT License
2.14k stars 155 forks source link

Change fenced code regex to include tildes #694

Closed Maarrk closed 5 months ago

Maarrk commented 5 months ago

This seems to fix #693

Yes, it did take me longer to write the report than the PR, no it is not funny.

zefhemel commented 5 months ago

Nice. I can't check this now but will have a look later. Is this really the only place matching triple backticks specifically? I'd be surprised.

Maarrk commented 5 months ago

Changing to draft, should also look at #675

Maarrk commented 5 months ago

Luckily, Markdown parsing with codemirror already handled this correctly, it was only being stopped by the language name. I've tried multiple combinations and haven't been able to break it so far.

I went through all triple backticks in the repo, and everything other was either .md files, some as info for the user, or writing a yaml block.

A remaining limitation is that both SETTINGS and STYLES still need to use exactly three backticks, but I didn't find any reliable way to fix that with regex only.

Should we add explanation of all the possibilities to Markdown/Basics#Code? Maybe not worth complicating it? If options other than triple backticks aren't mentioned anywhere, I don't feel that SETTINGS and STYLES need this described, just show the working example. Commonmark says it really concisely (emphasis mine):

sequence of at least three consecutive backtick characters (`) or tildes (~)

zefhemel commented 5 months ago

Thanks for this!