PHPBB3-13919 - Syntax highlighting in [code]

Discuss requests for comments/changes posted in the Issue Tracker for the development of phpBB. Current releases are 3.2/Rhea and 3.3/Proteus.
odf
Registered User
Posts: 4
Joined: Wed Nov 22, 2017 7:33 am

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by odf »

JoshyPHP wrote: Fri Jun 05, 2015 2:20 am 3.1 provides syntax highlighting for PHP (and only PHP) via highlight_string(), using the BBCode [code=php].

3.2 has no syntax highlighting in code blocks for any language. My recommendation is to use a JavaScript highlighter such as highlight.js or SyntaxHighlighter. My preference goes to highlight.js because it automatically detects the language of the source and it also requires one script tag to be installed. Both are available on various CDNs.

I don't know whether 3.2 should provide syntax highlighting at all. As far as I'm concerned, I wrote an extension for it to see how hard it would be to implement. All it takes is a script block in overall_footer to dynamically load highligher.js whererever needed. It costs 490 bytes per page. Unminified code here.
Hi JoshyPHP s9e/highlighter looks great, I installed it on a board run by phpBB 3.2 and tried it but does not seem to work! What might be a problem?

odf
Registered User
Posts: 4
Joined: Wed Nov 22, 2017 7:33 am

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by odf »

3Di wrote: Sat Apr 22, 2017 3:52 am David, honestly I was looking at https://cdn.rawgit.com/google/code-pret ... rettify.js and I didn't see the 2013 on line 3 at the time I posted, my fault. The github link comes in handy, forked as well.

Well, I know the Joshyphp's extension already, but I am not completely satisfied of the results (not a Joshy's fault indeed).
DavidIQ wrote: Sat Apr 22, 2017 3:15 am Honestly don't know why this is even being brought up anyways since there is a semi-official extension for syntax highlighting already:
hanakin wrote: Sat Mar 04, 2017 11:50 pm there are cases that could be made for code blocks that should be highlighted and others they should not
That's why.. https://github.com/3D-I/code-prettify#h ... ed-as-code
Can you provide instructions on how to use https://github.com/3D-I/code-prettify#h ... ed-as-code,
https://github.com/google/code-prettify, https://github.com/google/code-prettify ... started.md on phpBB 3.2?

User avatar
JoshyPHP
Registered User
Posts: 381
Joined: Fri Jul 08, 2011 9:43 pm

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by JoshyPHP »

odf wrote: Wed Nov 22, 2017 8:24 am Hi JoshyPHP s9e/highlighter looks great, I installed it on a board run by phpBB 3.2 and tried it but does not seem to work! What might be a problem?
Hundreds, maybe thousands of things. If you post a link to your board that will narrow the scope.

User avatar
3Di
Registered User
Posts: 951
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by 3Di »

odf wrote: Wed Nov 22, 2017 8:36 am
3Di wrote: Sat Apr 22, 2017 3:52 am David, honestly I was looking at https://cdn.rawgit.com/google/code-pret ... rettify.js and I didn't see the 2013 on line 3 at the time I posted, my fault. The github link comes in handy, forked as well.

Well, I know the Joshyphp's extension already, but I am not completely satisfied of the results (not a Joshy's fault indeed).
DavidIQ wrote: Sat Apr 22, 2017 3:15 am Honestly don't know why this is even being brought up anyways since there is a semi-official extension for syntax highlighting already:
hanakin wrote: Sat Mar 04, 2017 11:50 pm there are cases that could be made for code blocks that should be highlighted and others they should not
That's why.. https://github.com/3D-I/code-prettify#h ... ed-as-code
Can you provide instructions on how to use https://github.com/3D-I/code-prettify#h ... ed-as-code,
https://github.com/google/code-prettify, https://github.com/google/code-prettify ... started.md on phpBB 3.2?
Not really, I forked the repo in order to play with it and I haven't till now developped an extension for phpBB which uses it. To add, what stopped me to go ahead here has been the fact I read that's not so accurate with the PHP code.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades

OxCom
Registered User
Posts: 1
Joined: Fri Apr 06, 2018 1:20 pm

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by OxCom »

You can try to use my extension. It should work on 3.1.x, but it should also work on 3.2.x

User avatar
3Di
Registered User
Posts: 951
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano 🇮🇹 Frankfurt 🇩🇪
Contact:

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by 3Di »

Thanks for the interest.

We went to codemirror due to its power, as an example here's the rendered PHP with lines.
A grab from our extension's environment, in the future I will see to extract the code in order to make a separated extension from it.
.
codemirror_php.png
.
There in ACP the textarea has been limited on purpose.
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Want to compensate me for my interest? Donate
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades

ZoriaRPG
Registered User
Posts: 1
Joined: Fri Apr 03, 2020 10:36 pm

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by ZoriaRPG »

OxCom wrote: Fri Apr 06, 2018 2:20 pm You can try to use my extension. It should work on 3.1.x, but it should also work on 3.2.x
I'm trying to set this up on 3.3.0, but it isn't appearing in the ACP. Any suggestions, or is it simply incompatible?

User avatar
david63
Registered User
Posts: 355
Joined: Mon Feb 07, 2005 7:23 am

Re: PHPBB3-13919 - Syntax highlighting in [code]

Post by david63 »

ZoriaRPG wrote: Fri Apr 03, 2020 10:39 pm
OxCom wrote: Fri Apr 06, 2018 2:20 pm You can try to use my extension. It should work on 3.1.x, but it should also work on 3.2.x
I'm trying to set this up on 3.3.0, but it isn't appearing in the ACP. Any suggestions, or is it simply incompatible?
You should be asking that question in the support area for that extension
David
Remember: You only know what you know -
and you do not know what you do not know!

Post Reply