Closed rebelC0der closed 1 year ago
Apparently, this was reported in 2020: https://discuss.flarum.org/d/22635-how-to-change-syntax-highlighting/20
In the interest of eventually allowing CSP headers and removing scripts from textformatter content, maybe the correct action here would be removing highlighting this way in favor of explicitly calling highlightjs.
In the interest of eventually allowing CSP headers and removing scripts from textformatter content, maybe the correct action here would be removing highlighting this way in favor of explicitly calling highlightjs.
I have tried the highlight.js
extension, and it seems to be broken (syntax highlighting is broken, does not "respect" the theming):
I am wondering if there is some kind of hack/workaround for this, as I am waiting for this to work to start my community, which is code/programming focused, and this is one of the main features I need to work.
I started thinking about making a Flarum extension that would do server-side code highlighting. It would produce a "highlight.js compatible" HTML result while parsing the newly posted messages, this way the code parsing and highlighting is only done once. The clients would only have to include a CSS stylesheet. I will post an update if I finally start to do it.
I started thinking about making a Flarum extension that would do server-side code highlighting. It would produce a "highlight.js compatible" HTML result while parsing the newly posted messages, this way the code parsing and highlighting is only done once. The clients would only have to include a CSS stylesheet. I will post an update if I finally start to do it.
Got you. Do you know of any workaround that could be used now, as I am blocked from starting my community for a few weeks now, because of this bug?
So I started this extension today: club-1/flarum-ext-server-side-highlight.
It works well but is still has a few issues that I would like to address:
That said it currently provides the following advantages:
If you want to try it you can use the "repository" feature of composer, but I will probably create the package on packagist soon.
@n-peugnet Thank you so much. I will wait for you to add the package to the packagist. Let me know when you have done that, and also how can I tip you? I don't see a tip/support on your GitHub page.
@RebelCoderRU:
I will wait for you to add the package to the packagist. Let me know when you have done that
I published it on packagist and just released v0.2.0 that adds highlighting in the preview: https://packagist.org/packages/club-1/flarum-ext-server-side-highlight
and also how can I tip you? I don't see a tip/support on your GitHub page.
I did not take the time/motivation to setup it, I just applied for GitHub sponsors but it takes some time to receive the validation.
@n-peugnet Just tested it and it has highlighting/theme issues:
But the highlighting works during the editing:
Do I need to disable some other extension?
@RebelCoderRU: you should open an issue in my repo. It looks like there are two problems here. First I should add a note about the fact that the messages need to be reparsed (for example by editing them). Also it seems the dark theme is not properly detected, are you not using the "dark mode" switch in the appearance settings of Flarum ?
@n-peugnet
are you not using the "dark mode" switch in the appearance settings of Flarum ?
Yes, correct.
messages need to be reparsed (for example by editing them)
Yes, I have tried that, and it seems to work as expected, after I Edit -> Save.
How hard is it to change the theme of the highlighting? Even though it now works, colors are very bad, hard to read:
Current Behavior
Code snippets are not highlighted when a post is loaded/opened. Highlighting is enabled after a page refresh (video URL attached)
Steps to Reproduce
Expected Behavior
Code highlighting work when a post, containing code snippets, is opened.
Screenshots
Video: here
Environment
Output of
php flarum info
Full info above :arrow_double_up:
Possible Solution
For devs to review
Additional Context
n/a