-
-
Notifications
You must be signed in to change notification settings - Fork 827
Only syntax highlight if language was specified #1074
Only syntax highlight if language was specified #1074
Conversation
Can one of the admins verify this patch? |
Currently |
(@ara4n ping? <3) |
sorry for totally missing this - it looks good. Only feedback would be: |
Hmm, I'll look into how SyncedSettings works, and how to add a Riot toggle setting then. |
it should be two lines - one to add the definition to UserSettings and one to check it in TextualBody. |
44e2d02
to
0fce921
Compare
This is required to be able to specify the highlight language in fenced blocks like the following: ```python print("foo") ``` Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
The highlight.js autodetection is finicky and often wrong, so disable highlighting unless the language was explicitly specified, or if the user has explicitly enabled it in the settings. Fixes element-hq/element-web#508. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
0fce921
to
48c3217
Compare
@ara4n Fixed |
lgtm - thanks :) |
cough #1074 (comment) /cough |
The fact that it means code blocks in general are illegible on dark theme is really infuriating, as someone who uses dark theme a lot. I've had to turn on auto-syntax highlighting to fix this. I think we should still default to auto-highlighting, and let people disable it instead. |
Or the style could be fixed instead, and @ara4n said a few weeks ago that he'd done the same fix to the regular theme already, so shouldn't be hard. I have no clue where said stylesheet is, or what he changed though. And the auto-detection is pretty much always wrong, which is why we started looking into disabling it at all. |
Currently we always try to syntax highlight anything within backticks, which leads to things like
fooa_bar
being highlighted as autohotkey automatically by highlight.js. There isn't really any good way to autodetect the language for things like that, so instead this PR changes the behavior to only try to syntax highlight if a language was passed when sending a full-fledged fenced codeblock:This fixes element-hq/element-web#508.