tulir / gomuks

A terminal based Matrix client written in Go.
https://maunium.net/go/gomuks
GNU Affero General Public License v3.0
1.3k stars 124 forks source link

Keep whitespaces at the extremities of codeblocks #444

Open n-peugnet opened 8 months ago

n-peugnet commented 8 months ago

This is an old commit I forgot to send, as a follow-up to #387

Now that codeblocks tokens are correctly parsed, there is no need anymore for parsing its content and then extracting its plaintext version. This allows to save some computation and to preserve the whitespaces at the beginning and end of a codeblock.

Previously, messages containing only an empty codeblock where not displayed. Now the text of the codeblock defaults to '\n' so the message is always displayed.

tulir commented 8 months ago

Looks a bit sus since code blocks can contain HTML 🤔

n-peugnet commented 8 months ago

Looks a bit sus since code blocks can contain HTML 🤔

I'll check again, as I don't exactly remember why I made this commit like this (that's why I marked this PR as draft). But from my limited testing, HTML in code block seems to be handled by parser.syntaxHighlight()