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.
User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin »

prismjs is the current standard for highlighting

www.prismjs.com
https://github.com/PrismJS/prism
Donations welcome via Paypal Image

Rhino.Freak
Registered User
Posts: 48
Joined: Thu Dec 24, 2015 10:47 am

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

Post by Rhino.Freak »

So is it coming in for 3.3? I hope it is?
I tried to implement and currently using Pretty code by Google on my 3.1 test forum.. It sort of works but sort of doesn't. Having it in core would be great.

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin »

not sure if u r referring to me or joshyphp, but as far as prismjs that depends on the new theme. It will probably not be a major thought until its finished, but it will integrate easily enough with some minor changes in the backend
Donations welcome via Paypal Image

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin »

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.
not sure how the ext works but as it is now with 3.2 it does not produce the code properly from the parsser in that when we use [code=xxx] we do not get the expected result in the html which should be

Code: Select all

<pre>
	<code class="xxx">
	</code>
</pre>
I think this at a minimum should be included into the core so that it can be used with whichever highlighter you wish to use. It should not be a breaking change so could possilby add it to 3.2.x
Donations welcome via Paypal Image

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 »

The extension only loads highlight.js from a CDN without modifying any BBCodes. highlight.js does its own auto-detection, it doesn't require a language hint although I believe it uses it if present. Is there a reason you want to use the language as class name?

User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin »

JoshyPHP wrote: Sat Mar 04, 2017 7:56 pm The extension only loads highlight.js from a CDN without modifying any BBCodes. highlight.js does its own auto-detection, it doesn't require a language hint although I believe it uses it if present. Is there a reason you want to use the language as class name?
I am not familiar with highlight.js , but we should be as agnostic as possible to whichever framework someone wants to use there are many and most require it. Also there are cases that could be made for code blocks that should be highlighted and others they should not
Donations welcome via Paypal Image

jesssy
Registered User
Posts: 1
Joined: Thu Apr 20, 2017 10:58 am

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

Post by jesssy »

Simple. With javaScript code prettifier:
http://devcodepro.com/view/34/6/Syntax- ... phpBB-3.2-

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 »

jesssy wrote: Thu Apr 20, 2017 11:01 am Simple. With javaScript code prettifier:
http://devcodepro.com/view/34/6/Syntax- ... phpBB-3.2-
Which is dated 2006, something newer and similar I could look at? I mean, not already mentioned here.
🆓 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

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1903
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

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

Post by DavidIQ »

Ummm what?
https://github.com/google/code-prettify

Honestly don't know why this is even being brought up anyways since there is a semi-official extension for syntax highlighting already: https://github.com/s9e/phpbb-ext-highlighter
Image

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 »

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
🆓 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

Post Reply