SyntaxHighlight GeSHi
From KevinWiki
(Difference between revisions)
(SyntaxHighlight GeSHi) |
|||
Line 1: | Line 1: | ||
- | [[Category: | + | [[Category:MediaWiki Related]] |
==Install SyntaxHighlight GeSHi== | ==Install SyntaxHighlight GeSHi== | ||
# In the directory where the wiki is installed. | # In the directory where the wiki is installed. |
Latest revision as of 11:36, 6 April 2009
Install SyntaxHighlight GeSHi
# In the directory where the wiki is installed. $ cd extensions $ sudo svn co http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/SyntaxHighlight_GeSHi $ cd SyntaxHighlight_GeSHi $ sudo svn co http://geshi.svn.sourceforge.net/svnroot/geshi/branches/RELEASE_1_0_X_STABLE/geshi-1.0.X/src/ geshi
-Add the following line to LocalSettings.php
require_once("extensions/SyntaxHighlight_GeSHi/SyntaxHighlight_GeSHi.php");
This is for editing the colour of highlighted java code generated by Extension:SyntaxHighlight GeSHi
Modification
- Open the file java5.php under geshi/geshi directory.
- Change this
'COMMENT_REGEXP' => array(
//Import and Package directives (Basic Support only)
'2 => '/(?:(?<=import[\\n\\s])|(?<=package[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*([a-zA-Z0-9_]+|\*)(?=[\n\s;])/i'),
to
'COMMENT_REGEXP' => array(
// javadoc comments
2 => '#/\*\*(?!\*).*\*/#sU',
//Import and Package directives (Basic Support only)
3 => '/(?:(?<=import[\\n\\s])|(?<=package[\\n\\s]))[\\n\\s]*([a-zA-Z0-9_]+\\.)*([a-zA-Z0-9_]+|\*)(?=[\n\s;])/i'),
- Change this
'KEYWORDS' => array( 1 => 'color: #000000; font-weight: bold;', 2 => 'color: #000000; font-weight: bold;', 3 => 'color: #006600; font-weight: bold;', 4 => 'color: #006600; font-weight: bold;',
to
1 => 'color: #7F0058; font-weight: bold;', 2 => 'color: #7F0058; font-weight: bold;', 3 => 'color: #7F0058; font-weight: bold;', 4 => 'color: #7F0058; font-weight: bold;',
- Change this
'COMMENTS' => array( 1 => 'color: #666666; font-style: italic;', 2 => 'color: #006699;', 'MULTI' => 'color: #666666; font-style: italic;' ),
to
'COMMENTS' => array( 1 => 'color: #666666; font-style: italic;', 1 => 'color: #3F8088;', // // 2 => 'color: #3366BB;', // /** */ 'MULTI' => 'color: #477B5B;'//#67987E;' // /* */ ),
Test
- Now it has this kind of syntax highlight which is similar to the one from Eclipse.
<source lang="java5"> /** * @author Kevin * @version 1.0 */ public class Person { /* * the name of Person */ private String name; /** * Constructs Person object with the given name. * @param name the given name. */ public Person(name) { // sets the name of person. this.name = name; } /** * Returns the name of person. * @return the name of person. */ public String getName() { /* test */ return name; } } </source>
/** * @author Kevin * @version 1.0 */ public class Person { /* * the name of Person */ private String name; /** * Constructs Person object with the given name. * @param name the given name. */ public Person(name) { // sets the name of person. this.name = name; } /** * Returns the name of person. * @return the name of person. */ public String getName() { /* test */ return name; } }