[MODDB] phpBB Syntax Highlighter - 1.0.12

Moderator: Moderators

<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Wed Apr 22, 2009 7:57 am

[MODDB] phpBB Syntax Highlighter - 1.0.12

Modification Name: Syntax Highlighter
Author: UseLess
Modification Description: Syntax highlighting (using GeShi) with support for 132 programming/scripting languages
Modification Version: 1.0.12
Styles: Prosilver
Languages: English
Demo URL: Here
Home Page: http://www.phpbbstyles.co.uk/info/
Download link: Attached Below.

MODDB Post: http://www.phpbb.com/community/viewtopi ... &t=1697035

Quote from: Note
This mod is 'hooked' into phpBB and as such it is called AFTER phpBB has already parsed the message for any BBCodes phpBB recognises. This mod then parses the, as yet unparsed, 'syntax' tag and produces it's output.


The Long Description:

Due to a recent suggestion by mrbaseball34 the mod has been altered a little. You now have a choice of how you want the output to be shown. By using the BBCode tag [syntax] on it's own you will get the output displayed with line numbers, there is no syntax highlighting, and you can also specify the following options:

Basic Syntax allowed options
  • start = " x " - Line number to start at
  • filename = " filename for code when downloaded "
  • highlight = " line numbers to highlight seperated with , or - for consecutive lines " - NOT used if a language is specified
  • You may also use [ highlight ] ... [ /highlight ] to highlight part of a line, to highlight a full line use the option above
Note: By using [syntax=php] your specifying a language so the above options become invalid.

If you specify a language, for syntax highlighting, by using the following option: lang=mysql then the following options may be specified:

Language Syntax allowed options
  • lang = " php | delphi | css | mysql | html4strict " - over 130 languages supported
  • start = " x " - Line number to start at
  • filename = " filename for code when downloaded "
  • lines = " geshi-n | n | geshi-f | f " - how lines are to be shown, with line numbers and with fancy line numbers
  • fancy = " 5 " - Specifies that every 5th line is to be fancy, only used if the lines option is set to 'geshi-f' or 'f'

By default if a language is specified then it will be shown without line numbers, if you want line numbers then add a lines option.

You may now also use the language as a BBCode tag, this is disabled by default, so you can use:
  Code:
[delphi] ... [/delphi]

or you can also specify options:
  Code:
[delphi filename=test.pas lines=geshi-f fancy=3] ... [/delphi]

You can replace 'delphi' in the above examples with any of the supported languages, i.e.:
  Code:
[php lines=n] ... [/php]
[z80] .., [/z80]
[html4strict] ... [/html4strict]


If you do not wish to specify any other attributes then you may use the 1st format below. If you wish to specify 1 or more attributes then you must use the 2nd format and specify 'lang="delphi"' with 'delphi' being the syntax to use or use the language as the tag.

There is also an option to download the code, if a filename is specified this will be used instead of the default code id.

Usage
  Code:
[syntax="php"] code in here [/syntax]
[syntax lang="php" filename="file.php" start="10" lines=n] code in here [/syntax]


Notes
  1. The Demo on this site uses the Full BBCode parser which has more BBCode tags, however the Syntax Highlighting is the same.
  2. There is an 'install.txt' file located in the 'contrib' dir for those that are not fans of the ModX format
  3. There is an 'update.txt' file located in the 'contrib' dir for those that want to update from a previous version
  4. Quickest way to install the mod is to copy the contents of the 'root' dir to the root of your forum.
  5. Then make the alterations to the 3 files
  6. Then refresh the Theme data from the ACP
  7. Then clear the cache, or you could just refresh the Template data from the ACP.

Thanks are due to:
  • CyberAlien - for releasing the original BBCode parser to the public.
  • baboon - for (at time of posting this) a part complete Spanish translation
  • mrbaseball34 - for the idea to use the language as a BBCode tag
  • Bigwebmaster - for pointing out some errors I'd missed... and the fact that 'debug mode' is there for a reason.

SubSilver 2:
Now supports SubSilver 2 you'll obviously need the mod and then this:
Syntax: [ Download ] [ Hide ]
Using phpBB MOD Template Syntax Highlighting
#
#-----[ OPEN ]-------------------------------------------------------
#

styles/subsilver2/template/overall_header.html

#
#-----[ FIND ]-------------------------------------------------------
#

<title>{SITENAME} &bull; <!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

#
#-----[ AFTER, ADD ]-------------------------------------------------
#

<script type="text/javascript" src="{T_TEMPLATE_PATH}/xs_bbcode_fn.js"></script>
<script type="text/javascript" src="{ROOT_PATH}classes/scripts/select_expand_bbcodes.js"></script>

#
#-----[ FIND ]-------------------------------------------------------
#

<link rel="stylesheet" href="{T_STYLESHEET_LINK}" type="text/css" />

#
#-----[ AFTER, ADD ]-------------------------------------------------
#

<link rel="stylesheet" href="{T_THEME_PATH}/ul_syntax_highlighter.css" type="text/css" />

#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------------
#
# EoM
Parsed in 0.129 seconds, using GeSHi 1.0.8.11

And this, download the file and place it in: styles/subsilver2/theme/ul_syntax_highlighter.css you must make sure the filename of the CSS file is 'ul_syntax_highlighter.css'.
[css filename="ul_syntax_highlighter.css"]/*
SubSilver 2
XS Syntax Highlighter CSS
*/
.postbody .syntax {
color: #444;
display: block;
margin: 5px auto;
width: 98%;
border: solid 1px #D0D0D0;
background-color: #FFF;
padding: 5px;
font-size: 1.0em;
font-family: Courier, 'Courier New', sans-serif;
line-height: 1.2em;
}
.postbody .syntax-header {
margin: 0;
margin-bottom: 5px;
padding-left: 3px;
padding-bottom: 3px;
border-bottom: solid 1px #E0E0E0;
font-size: 1.0em;
line-height: 1.2em;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: normal;
color: #808080;
}

.syntax-header a:link,
.syntax-header a:visited
{
color: #666;
text-decoration: none;
border-bottom: dotted 1px #666;
}
.syntax-header a:hover,
.syntax-header a:active
{
color: #FF1010;
text-decoration: none;
border-bottom: dotted 1px #FF1010;
}

.syntax-content {
padding: 0;
}

.syntax-list {
margin-top: 3px;
margin-right: 0;
margin-bottom: 3px;
}

li.syntax-row {
margin-left: 12px;
white-space: normal;
border-top: 1px #E0E0E0 solid;
color: #BBB;
wrap-option: emergency;
}
.syntax-row-text {
color: #444;
}

div.syntax li.syntax-row-highlight {
color: #FF1010;
border-color: #D8D8D8;
}

div.syntax li.syntax-row-highlight .syntax-row-text, span.syntax-row-highlight {
color: #FF1010;
}

li.syntax-row-first {
border-top: none;
}
/* Mini Table */
.minitable {
color: #444;
display: block;
margin: 5px 20px;
border: solid 1px #D0D0D0;
background-color: #FFF;
font-size: 12px;
}
.minitable-header {
background: #fff url({T_THEME_PATH}/images/bg_header.gif) top left repeat-x;
margin: 0;
margin-bottom: 5px;
padding-left: 5px;
padding-top: 7px;
padding-right: 5px;
border-bottom: solid 1px #D0D0D0;
font-size: 12px;
line-height: 1.2em;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #EDEFF4;
height: 21px;

}
.minitable-hideme {
font-size: 10px;
line-height: 1.2em;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-weight: bold;
color: #EEE;
float: right;
}
.minitable-hideme a, .minitable-hideme a:visited {
color: #eee;
text-decoration: none;
}
.minitable-hideme a:hover {
color: #fff;
text-decoration: none;
}
.minitable-contents {
padding-left: 5px;
padding-right: 5px;
padding-bottom: 5px;
line-height: 1.5;
text-align: left;
}
/* Hide content */
.hide-contents,
.hide-contents .quote-message {
color: #757575;
background-color: #F2F2F2;
border: 2px dotted #DEDEDE;
text-align: left;
padding: 5px;
}[/css]
Updates
  • updated to version 1.0.12 changes:
    • Now works in MCP when viewing reported posts preview
    • Fixed other issues when DEBUG mode was enabled
    • added method to remove the link stuff added by phpBB
  • updated to version 1.0.11 changes:
    • if the basic tag is used, i.e. [syntax] then the mod will add line numbers, as it previously did
    • changed 'syntax=' to 'lang='
    • if either [syntax=<lang name>] or [syntax lang=<lang name>] is used then, by default, no line numbers will be shown, see below for line number option
    • added lines option can be either 'lines=geshi-n' for normal geshi generated line numbers or 'lines=geshi-f' for fancy lines also generated by geshi
    • added fancy option which can only be used with the 'geshi-f' above to specify which lines should be fancy, i.e. if 5 is specified then every 5th line will be fancy
  • updated to version 1.0.9 changes:
    • issues pointed out by phpBB.com MOD team resolved and resubmitted for validation
    • to update to latest version:
        Code:
      download latest version
      unzip archive
      upload the following to remote server:
      includes/hooks/hook_syntax_highlighter.php
      language/en/mods/useless_xs_bbcode.php
      styles/prosilver/theme/ul_syntaxhighlighter.css
  • updated to version 1.0.8 changes:
    • updated GeSHi to version 1.0.8.4
    • to update see post below
  • updated to version 1.0.7 fixed various issues (see install.xml history section for details)
  • Updated GeSHi to version 1.0.8.3 (now supports 132 languages) changed mod version to 0.0.3
  • Changed status to RC and updated version to 1.0.4, made the following changes
    • fixed bug in bbc_download.php
    • altered CSS
    • Removed static text and added them to 'language/en/common.php'
  • Changed name of CSS Class to avoid possible future conflicts
Attachments
SyntaxHighlighter_1.0.12.zip
Release Candidate 5 ~ Version 1.0.12
Mod validated and in the MODDB
(653.02 KiB) Downloaded 1059 times
SyntaxHighlighter_1.0.11.zip
Release Candidate 4 ~ Version 1.0.11
(650.08 KiB) Downloaded 394 times
SyntaxHighlighter_1.0.9.zip
Release Candidate 3 ~ Version 1.0.9
Minor Issues resolved and resubmitted for validation.
(638.92 KiB) Downloaded 484 times
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Fri Apr 24, 2009 9:54 am

Re: [RC1] Syntax Highlighter - 1.0.6

CSS Example:
Syntax: [ Download ] [ Hide ]
Using CSS Syntax Highlighting
/*
        XS Syntax Highlighter CSS
*/

.content .code {
        color: #444;
        display: block;
        margin: 5px 20px;
        width: auto;
        border: solid 1px #D0D0D0;
        background-color: #FFF;
        padding: 5px;
        font-size: 0.9em;
        font-family: Courier, 'Courier New', sans-serif;
}
Parsed in 0.014 seconds, using GeSHi 1.0.8.11

Tag used above:
  Code:
[syntax="css"] ... [/syntax]

No Syntax Specified (you can then use the [highlight][/highlight] tag to highlight part of a line, the red text:
Syntax: [ Download ] [ Hide ]
  1. /* 
  2.     XS Syntax Highlighter CSS 
  3. */ 
  4. .content .code { 
  5.     color: #444; 
  6.     display: block; 
  7.     margin: 5px 20px; 
  8.     width: auto; 
  9.     border: solid 1px #D0D0D0; 
  10.     background-color: #FFF; 
  11.     padding: 5px; 
  12.     font-size: 0.9em; 
  13.     font-family: Courier, 'Courier New', sans-serif; 

Tag used above:
  Code:
[syntax] ... [/syntax]

As the CSS Example above but start line count at 10:
[css start="10" lines="geshi-n"]/*
XS Syntax Highlighter CSS
*/
.content .code {
color: #444;
display: block;
margin: 5px 20px;
width: auto;
border: solid 1px #D0D0D0;
background-color: #FFF;
padding: 5px;
font-size: 0.9em;
font-family: Courier, 'Courier New', sans-serif;
}[/css]
Tag used above:
  Code:
[css start="10" lines="geshi-n"] ... [/css]
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Tue Apr 28, 2009 8:06 am

Re: [RC1] Syntax Highlighter - 1.0.6

Greetings,

Updated to RC status and version 1.0.6

now works in PM, PM Preview, PM History, Message Review, Message Preview
altered bbc_download.php so you can now download from PMs
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Mon Jun 01, 2009 3:24 am

Re: [RC2] Syntax Highlighter - 1.0.8

Greetings,

Updated GeSHi to version 1.0.8.4 and mod version to 1.0.8
As only GeSHi has been updated you simply need to download the latest version and upload the following;
  • includes/geshi/*.* (i.e. all files in the dir as there are some new language files)
  • includes/geshi.php
  • includes/hooks/hook_syntax_highlighter.php
now supports 138 languages.
[ Hide ]
BBCode (Hooker) Version: 2.0.15 Release: 0 Build: 45
Oh! Err... BBCodes without adding custom ones...
The following BBCode tags are supported: version, quoter, syntax, spoil, spoiler, hide, marquee, marq, s, hr, sub, sup, ovl, table, countdown, youtube, rquote, nfo, gamertag

(224) Supported Syntaxes: 4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, phpbb, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xhtml, xml, xorg_conf, xpp, yaml, z80, zxbasic
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

Xanta

User avatar

Site Admin
Site Admin

Posts: 76

Joined: Wed Jan 14, 2009 12:59 pm

Location: UK

Post Mon Jun 01, 2009 3:35 am

Re: [RC2] Syntax Highlighter - 1.0.8

I really need to get around to installing this mod!

Maybe I will add it later when I attempt the 3.0.5 update...
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Mon Jun 01, 2009 3:47 am

Re: [RC2] Syntax Highlighter - 1.0.8

Greetings,

Well I just updated a local copy of a forum and it went ok there were a few issues but got it done in the end... waiting to see if CA will provide a list of style changes before making the remote update. As there are a few styles used on the forum and don't really fancy reinstalling the mods to the updated styles...
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

CorneN

Very New Member
Very New Member

Posts: 1

Joined: Sat Jun 13, 2009 6:40 pm

Post Sat Jun 13, 2009 7:58 pm

Re: [RC2] Syntax Highlighter - 1.0.8

Hi Useless,

I just installed RC2 of this mod on my forum and I like it alot. There's only one hickup that I need a bit of help with. Was the Mod intended for Subsilver2 type styles?

Everything seems to work well, except for the [download] feature, which downloads a bit of garbage and nothing else. If there is no immediate fix, is it possible to hide for the moment?
<<

UseLess

User avatar

Village Idiot
Village Idiot

Posts: 272

Joined: Thu Jan 08, 2009 9:57 pm

Location: North East UK

Post Sat Jun 13, 2009 10:47 pm

Re: [RC2] Syntax Highlighter - 1.0.8

Greetings,

In answer to your SubSilver 2 question: Nope.. could never get it to look nice, even on phpBB 2, so never bothered with SubSilver 2.

The download feature should work if you supply a link to your forum i'll take a look or you can post the contents of 'bbc_download.php' here.

If you want to disable it do this;
  Code:
#
#-----[ OPEN ]-------------------------------------------------------
#

includes/hooks/hook_syntax_highlighter.php

#
#-----[ FIND ]-------------------------------------------------------
#

         $can_download = (($this->code_post_id != 0) ? $this->code_post_id : 0);

#
#-----[ REPLACE WITH ]-----------------------------------------------
#

//         $can_download = (($this->code_post_id != 0) ? $this->code_post_id : 0);
         $can_download = false;

#
#-----[ SAVE/CLOSE ALL FILES ]---------------------------------------
#
# EoM
Movie Quote:
It's not the years honey, it's the mileage...
phpBB 3 Mods @ phpBBStyles
<<

CJ1985

Very New Member
Very New Member

Posts: 5

Joined: Wed Jun 24, 2009 1:44 pm

Post Wed Jun 24, 2009 1:56 pm

Re: [RC3] Syntax Highlighter - 1.0.9

I just installed this, very nice and very helpful! Now I noticed, when trying to do it like
Syntax: [ Download ] [ Hide ]
  1. code 
it didn't work, why is that?


Edit: Oh, wait... I just viewed my post, and it worked? How's that?!?!
<<

CJ1985

Very New Member
Very New Member

Posts: 5

Joined: Wed Jun 24, 2009 1:44 pm

Post Wed Jun 24, 2009 2:04 pm

Re: [RC3] Syntax Highlighter - 1.0.9

Sorry for double posting, however I am just curious as to why on your board it automatically does the download part, and why does it pull up the html syntax but on my board it doesn't?

This is what it looks like when I try the html parse:

Image

Then for like css it looks like this:

Image

So I know it's correct and everything, but the html part is what is getting me confused. Also, the part about the download part, that I want to automatically be added like you have here on your board.

Any suggestions? Also, sorry for double posting.
Next

Return to phpBB 3 Mods

Who is online

Users browsing this forum: No registered users and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for blacklist.org.
Time : 0.141s | 16 Queries | GZIP : Off