Skip to content

Commit

Permalink
Item8175: Support pure ascii-output without highlighting; return an e…
Browse files Browse the repository at this point in the history
…rror if the language is not supported

git-svn-id: http://svn.foswiki.org/trunk/DpSyntaxHighlighterPlugin@4053 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
AndrewJones authored and AndrewJones committed Jun 7, 2009
1 parent 3688673 commit e492f55
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 26 deletions.
20 changes: 11 additions & 9 deletions data/System/DpSyntaxHighlighterPlugin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Currently all the Foswiki syntax highlighting plugins use the same =%<nop>CODE%=

Version 1.2 of this plugin added support for using the %<nop>CODE_DP% syntax, which allows you to explicitly which plugin you want to highlight your code.

Clearly this is not the best solution to the problem of using more than one highlighting plugin. You can read the background on why this approach was taken in the [Foswikitask:Item1353][task report]].
Clearly this is not the best solution to the problem of using more than one highlighting plugin. You can read the background on why this approach was taken in the [[Foswikitask:Item1353][task report]].

---+++ Pre vs Textarea

Expand All @@ -48,6 +48,7 @@ The following languages are supported:
* delphi, pascal
* js, jscript, javascript
* pl, perl
* plain, ascii (no highlighting)
* php
* py, python
* ruby
Expand Down Expand Up @@ -84,14 +85,15 @@ function hello () {
| License: | [[http://www.gnu.org/licenses/gpl.html][GPL (Gnu General Public License)]] |
| Dp Syntax Highlighter License: | [[http://www.gnu.org/licenses/lgpl.html][LGPL (Gnu Lesser General Public License)]] |
| Change History: | <!-- versions below in reverse order -->&nbsp; |
| 29 Mar 2009 | 1.2: Added =%<nop>CODE_DP%= syntax so it can be used with other syntax highlighters (Foswikitask:Item1353) |
| 16 Mar 2009 | 1.1: Removed call to depreciated function. Will work correctly with TWikiCompatibilityPlugin disabled. |
| 25 Jan 2009 | Added missing screenshot Foswiki:Main.WillNorris |
| 07 Jan 2009 | 1.0: Ported to Foswiki; Will now use jQuery if found; Added support for Perl. Thanks to [[http://code.google.com/p/syntaxhighlighter/issues/detail?id=113&sort=-modified&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Modified][Marty Kube]]. |
| 25 Mar 2008 | Arthur Clemens: Added support for !ActionScript 3. Thanks to [[http://www.digitalflipbook.com/archives/2007/09/as3_syntax_high.php][Mark Walters]] (digitalflipbook.com). |
| 14646 | Fixed adding JS into highlighted HTML (#3) |
| 14642 | Upgrade highlighter to 1.5.1 |
| 14046 | Initial version |
| 06 Jun 2009 | 1.3: Added support for pure ascii-output without highlighting (Foswikitask:Item8175); Return an error if the language is not supported -- Foswiki:Main.AndrewJones |
| 29 Mar 2009 | 1.2: Added =%<nop>CODE_DP%= syntax so it can be used with other syntax highlighters (Foswikitask:Item1353) -- Foswiki:Main.AndrewJones |
| 16 Mar 2009 | 1.1: Removed call to depreciated function. Will now work correctly with TWikiCompatibilityPlugin disabled -- Foswiki:Main.AndrewJones |
| 25 Jan 2009 | Added missing screenshot -- Foswiki:Main.WillNorris |
| 07 Jan 2009 | 1.0: Ported to Foswiki; Will now use jQuery if found; Added support for Perl. Thanks to [[http://code.google.com/p/syntaxhighlighter/issues/detail?id=113&sort=-modified&colspec=ID%20Type%20Status%20Priority%20Milestone%20Owner%20Summary%20Modified][Marty Kube]] -- Foswiki:Main.AndrewJones |
| 25 Mar 2008 | Added support for !ActionScript 3. Thanks to [[http://www.digitalflipbook.com/archives/2007/09/as3_syntax_high.php][Mark Walters]] (digitalflipbook.com) -- Foswiki:Main.ArthurClemens |
| 14646 | Fixed adding JS into highlighted HTML (#3) -- Foswiki:Main.AndrewJones |
| 14642 | Upgrade highlighter to 1.5.1 -- Foswiki:Main.AndrewJones |
| 14046 | Initial version -- Foswiki:Main.AndrewJones |
| Dp Syntax Highlighter Home | http://code.google.com/p/syntaxhighlighter |
| Plugin Home: | http://foswiki.org/Extensions/DpSyntaxHighlighterPlugin |
| Support: | http://foswiki.org/Support/DpSyntaxHighlighterPlugin |
Expand Down
40 changes: 23 additions & 17 deletions lib/Foswiki/Plugins/DpSyntaxHighlighterPlugin.pm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Plugin for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2007 - 2009 Andrew Jones, andrewjones86@googlemail.com
# Copyright (C) 2007 - 2009 Andrew Jones, http://andrew-jones.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
Expand All @@ -20,7 +20,7 @@ use strict;
use vars qw( $VERSION $RELEASE $NO_PREFS_IN_TOPIC $SHORTDESCRIPTION $pluginName $rootDir $doneHead );

our $VERSION = '$Rev: 9813$';
our $RELEASE = '1.2';
our $RELEASE = '1.3';
our $pluginName = 'DpSyntaxHighlighterPlugin';
our $NO_PREFS_IN_TOPIC = 1;
our $SHORTDESCRIPTION = 'Client side syntax highlighting using the [[http://code.google.com/p/syntaxhighlighter/][dp.SyntaxHighlighter]]';
Expand Down Expand Up @@ -80,21 +80,27 @@ sub _handleTag {
# brush
my $brush = '';
for ($lang){
/as3|actionscript3/i and $brush = "AS3", last;
/css/i and $brush = "Css", last;
/c#|c-sharp|csharp/i and $brush = "CSharp", last;
/^c$|cpp|c\+\+/i and $brush = "Cpp", last;
/vb|vb\.net/i and $brush = "Vb", last;
/delphi|pascal/i and $brush = "Delphi", last;
/js|jscript|javascript/i and $brush = "JScript", last;
/^java$/i and $brush = "Java", last;
/php/i and $brush = "Php", last;
/pl|perl/i and $brush = "Perl", last;
/py|python/i and $brush = "Python", last;
/ruby|ror|rails/i and $brush = "Ruby", last;
/sql/i and $brush = "Sql", last;
/xml|xhtml|xslt|html/i and $brush = "Xml", last;
/as3|actionscript3/ and $brush = "AS3", last;
/css/ and $brush = "Css", last;
/c#|c-sharp|csharp/ and $brush = "CSharp", last;
/^c$|cpp|c\+\+/ and $brush = "Cpp", last;
/vb|vb\.net/ and $brush = "Vb", last;
/delphi|pascal/ and $brush = "Delphi", last;
/js|jscript|javascript/ and $brush = "JScript", last;
/^java$/ and $brush = "Java", last;
/php/ and $brush = "Php", last;
/^pl$|perl/ and $brush = "Perl", last;
/plain|ascii/ and $brush = "Plain", last;
/py|python/ and $brush = "Python", last;
/ruby|ror|rails/ and $brush = "Ruby", last;
/sql/ and $brush = "Sql", last;
/xml|xhtml|xslt|html/ and $brush = "Xml", last;
}

# language not found; return error
return "<span class='foswikiAlert'>$pluginName error: The language \"$lang\" is not supported.</span>"
if $brush eq '';

$out .= "<script type=\"text/javascript\" src='$rootDir/Scripts/shBrush$brush.js'></script>";

_doHead();
Expand Down Expand Up @@ -131,7 +137,7 @@ if (typeof jQuery != 'undefined') {
// foswiki
foswiki.Event.addLoadEvent(dp.SyntaxHighlighter.render);
} else {
alert("Can't add load event for DpSyntaxHighlighterPlugin. Please contact your System Administrator.");
alert("Can't add load event for $pluginName. Please contact your System Administrator.");
}
</script>
EOT
Expand Down
1 change: 1 addition & 0 deletions lib/Foswiki/Plugins/DpSyntaxHighlighterPlugin/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushJScript
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushJava.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushPerl.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushPhp.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushPlain.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushPython.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushRuby.js 0644
pub/System/DpSyntaxHighlighterPlugin/dp.SyntaxHighlighter/Scripts/shBrushSql.js 0644
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Code Syntax Highlighter.
* Version 1.5.2
* Copyright (C) 2004-2008 Alex Gorbatchev
* http://www.dreamprojections.com/syntaxhighlighter/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Plain brush contributed by Andrew Jones - http://andrew-jones.com */
dp.sh.Brushes.Plain = function()
{
var funcs = '';
var keywords = '';

this.regexList = [];

this.CssClass = 'dp-plain';
this.Style = '';
}

dp.sh.Brushes.Plain.prototype = new dp.sh.Highlighter();
dp.sh.Brushes.Plain.Aliases = ['plain', 'ascii'];

0 comments on commit e492f55

Please sign in to comment.