-
-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code syntax highlighting bug #3794
Comments
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. |
I have tried the |
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. |
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 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
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 ? |
Yes, correct.
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 version:Desired version (or at least as readable in both, dark and light mode): |
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 ⏫
Possible Solution
For devs to review
Additional Context
n/a
The text was updated successfully, but these errors were encountered: