tulir / gomuks

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

Fix mangled newlines in some code blocks #387

Closed n-peugnet closed 2 years ago

n-peugnet commented 2 years ago

Because some tokens can contain newlines and not only comment tokens, I removed the comments specific code to handle newlines in a more generic way.

Before

2022-10-10-184125_975x737_scrot

After

2022-10-10-185740_975x722_scrot

Before

2022-10-10-184340_765x527_scrot

After

2022-10-10-184522_765x527_scrot

Fixes #274 Fixes #213

n-peugnet commented 2 years ago

I just found out this change kind of breaks the "plain text" mode (^L). I'm investigating this right now.

n-peugnet commented 2 years ago

I added a third patch to preserve the whitespace characters at the beginning and end of the codeblocks. I am not sure if it could cause other problems, but it seems to be sensible and I didn't have any issue with my limited testing. It does not affect the plaintext mode though.

This is mostly important for indentation when the first line does not start from the first column:

Before f2137558ea0072607b8fb83a909e91f151df58a3

2022-10-13-175505_863x182_scrot

After f2137558ea0072607b8fb83a909e91f151df58a3

2022-10-13-175411_863x182_scrot

EDIT: This third patch seems to introduce a crash sometimes.

n-peugnet commented 2 years ago

As I just had a crash with the third commit. I removed it from this pull request (and rebased it by the way) to be able to merge it faster.