PHPBB3-13919 - Syntax highlighting in [code]

Discuss requests for comments/changes posted in the Issue Tracker for the development of phpBB. Upcoming releases are 3.2/Rhea and 3.3.
User avatar
hanakin
Infrastructure Team
Infrastructure Team
Posts: 793
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin » Wed Sep 14, 2016 7:55 pm

prismjs is the current standard for highlighting

www.prismjs.com
https://github.com/PrismJS/prism

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 » Sun Nov 20, 2016 8:00 am

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
Infrastructure Team
Infrastructure Team
Posts: 793
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin » Mon Nov 21, 2016 5:53 am

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

User avatar
hanakin
Infrastructure Team
Infrastructure Team
Posts: 793
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin » Sat Mar 04, 2017 4:55 pm

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

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

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

Post by JoshyPHP » 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?

User avatar
hanakin
Infrastructure Team
Infrastructure Team
Posts: 793
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

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

Post by hanakin » Sat Mar 04, 2017 11:50 pm

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

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

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

Post by jesssy » Thu Apr 20, 2017 11:01 am

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

User avatar
3Di
Registered User
Posts: 695
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano (I) Frankfurt (D)
Contact:

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

Post by 3Di » Sat Apr 22, 2017 2:40 am

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.
Want to compensate me for my interest? Don't ask me, just do it
I'm available for custom phpBB jobs, you can PM me the details.
New: my Live Board, Extensions and Tools for phpBB - Men at works.

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

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

Post by DavidIQ » Sat Apr 22, 2017 3:15 am

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: 695
Joined: Tue Nov 01, 2005 9:50 pm
Location: Milano (I) Frankfurt (D)
Contact:

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

Post by 3Di » 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
Want to compensate me for my interest? Don't ask me, just do it
I'm available for custom phpBB jobs, you can PM me the details.
New: my Live Board, Extensions and Tools for phpBB - Men at works.

Post Reply