Automatic code highlighting broken in fullscreen code view

I think the issue is here :thinking: :

https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse/app/lib/highlight-syntax.js#L36-L52

You have lang-auto class name applied with markdown code and automatically removed here so the library can guess the language.

However, when you go fullscreen, lang-auto is no longer in the element, and you have only language-<detected-language-here> class name here. Thus, lang is undefined.

A maybe fix could be here – if lang-auto is not found, look for language-<..>

const m = className.match(/^lang-(.+)$/);
→
const m = className.match(/^`(?:lang|language)-(.+)$/);

1 Like