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.
odf
Registered User
Posts: 2
Joined: Wed Nov 22, 2017 7:33 am

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

Post by odf » Wed Nov 22, 2017 8:24 am

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: 2
Joined: Wed Nov 22, 2017 7:33 am

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

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

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 » Thu Nov 23, 2017 1:21 pm

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: 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 Nov 25, 2017 11:27 pm

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