summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-08-14 16:48:19 +0200
committerFlorian Pritz <bluewind@xssn.at>2010-08-14 17:20:34 +0200
commitb82315dfebf9a77d8b5114afcab0cad27c3f40ac (patch)
tree83d704aaba7bbde5b85f749df96a38c10fa0076d
parent2f8e0832796ad9e7f64e9b4e6dbe40f995b3a76d (diff)
switch to pygments for highlighting
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--data/paste.css81
-rwxr-xr-xscripts/syntax-highlighting.sh163
-rw-r--r--system/application/models/file_mod.php10
3 files changed, 73 insertions, 181 deletions
diff --git a/data/paste.css b/data/paste.css
index 413c916cc..cb6be98dc 100644
--- a/data/paste.css
+++ b/data/paste.css
@@ -73,20 +73,67 @@ a.raw_link {
color: lightblue;
}
-table.content .num { color:#2928ff; }
-table.content .esc { color:#cc3782; }
-table.content .str { color:#3782cc; }
-table.content .dstr { color:#818100; }
-table.content .slc { color:#838183; font-style:italic; }
-table.content .com { color:#838183; font-style:italic; }
-table.content .dir { color:#008200; }
-table.content .sym { color:#000000; }
-table.content .kwa { color:#000000; font-weight:bold; }
-table.content .kwb { color:#830000; }
-table.content .kwc { color:#000000; font-weight:bold; }
-table.content .kwd { color:#010181; }
-table.content .kwe { color:#008200; }
-table.content .pps { color:#818100; }
-table.content .ppc { color:#008200; }
-table.content .opt { color:#000000; }
-table.content .lin { color:#555555; }
+/* pygments */
+.code .hll { background-color: #ffffcc }
+.code { background: #ffffff; }
+.code .c { color: #808080 } /* Comment */
+.code .err { color: #F00000; background-color: #F0A0A0 } /* Error */
+.code .k { color: #008000; font-weight: bold } /* Keyword */
+.code .o { color: #303030 } /* Operator */
+.code .cm { color: #808080 } /* Comment.Multiline */
+.code .cp { color: #507090 } /* Comment.Preproc */
+.code .c1 { color: #808080 } /* Comment.Single */
+.code .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
+.code .gd { color: #A00000 } /* Generic.Deleted */
+.code .ge { font-style: italic } /* Generic.Emph */
+.code .gr { color: #FF0000 } /* Generic.Error */
+.code .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.code .gi { color: #00A000 } /* Generic.Inserted */
+.code .go { color: #808080 } /* Generic.Output */
+.code .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.code .gs { font-weight: bold } /* Generic.Strong */
+.code .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.code .gt { color: #0040D0 } /* Generic.Traceback */
+.code .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
+.code .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
+.code .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
+.code .kp { color: #003080; font-weight: bold } /* Keyword.Pseudo */
+.code .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
+.code .kt { color: #303090; font-weight: bold } /* Keyword.Type */
+.code .m { color: #6000E0; font-weight: bold } /* Literal.Number */
+.code .s { background-color: #fff0f0 } /* Literal.String */
+.code .na { color: #0000C0 } /* Name.Attribute */
+.code .nb { color: #007020 } /* Name.Builtin */
+.code .nc { color: #B00060; font-weight: bold } /* Name.Class */
+.code .no { color: #003060; font-weight: bold } /* Name.Constant */
+.code .nd { color: #505050; font-weight: bold } /* Name.Decorator */
+.code .ni { color: #800000; font-weight: bold } /* Name.Entity */
+.code .ne { color: #F00000; font-weight: bold } /* Name.Exception */
+.code .nf { color: #0060B0; font-weight: bold } /* Name.Function */
+.code .nl { color: #907000; font-weight: bold } /* Name.Label */
+.code .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.code .n { color: #0e84b5; font-weight: bold } /* Name */
+.code .nt { color: #007000 } /* Name.Tag */
+.code .nv { color: #906030 } /* Name.Variable */
+.code .ow { color: #000000; font-weight: bold } /* Operator.Word */
+.code .w { color: #bbbbbb } /* Text.Whitespace */
+.code .mf { color: #6000E0; font-weight: bold } /* Literal.Number.Float */
+.code .mh { color: #005080; font-weight: bold } /* Literal.Number.Hex */
+.code .mi { color: #0000D0; font-weight: bold } /* Literal.Number.Integer */
+.code .mo { color: #4000E0; font-weight: bold } /* Literal.Number.Oct */
+.code .sb { background-color: #fff0f0 } /* Literal.String.Backtick */
+.code .sc { color: #0040D0 } /* Literal.String.Char */
+.code .sd { color: #D04020 } /* Literal.String.Doc */
+.code .s2 { background-color: #fff0f0 } /* Literal.String.Double */
+.code .se { color: #606060; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */
+.code .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */
+.code .si { background-color: #e0e0e0 } /* Literal.String.Interpol */
+.code .sx { color: #D02000; background-color: #fff0f0 } /* Literal.String.Other */
+.code .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */
+.code .s1 { background-color: #fff0f0 } /* Literal.String.Single */
+.code .ss { color: #A06000 } /* Literal.String.Symbol */
+.code .bp { color: #007020 } /* Name.Builtin.Pseudo */
+.code .vc { color: #306090 } /* Name.Variable.Class */
+.code .vg { color: #d07000; font-weight: bold } /* Name.Variable.Global */
+.code .vi { color: #3030B0 } /* Name.Variable.Instance */
+.code .il { color: #0000D0; font-weight: bold } /* Literal.Number.Integer.Long */
diff --git a/scripts/syntax-highlighting.sh b/scripts/syntax-highlighting.sh
deleted file mode 100755
index 845d4a6e4..000000000
--- a/scripts/syntax-highlighting.sh
+++ /dev/null
@@ -1,163 +0,0 @@
-#!/bin/sh
-# Note: the highlight command (http://www.andre-simon.de/) uses css for syntax
-# highlighting, so you'll probably want something like the following included
-# in your css file (generated by highlight 2.4.8 and adapted for cgit):
-#
-# table.blob .num { color:#2928ff; }
-# table.blob .esc { color:#ff00ff; }
-# table.blob .str { color:#ff0000; }
-# table.blob .dstr { color:#818100; }
-# table.blob .slc { color:#838183; font-style:italic; }
-# table.blob .com { color:#838183; font-style:italic; }
-# table.blob .dir { color:#008200; }
-# table.blob .sym { color:#000000; }
-# table.blob .kwa { color:#000000; font-weight:bold; }
-# table.blob .kwb { color:#830000; }
-# table.blob .kwc { color:#000000; font-weight:bold; }
-# table.blob .kwd { color:#010181; }
-
-case "$1" in
- *.4gl) exec /usr/bin/highlight -f -I -O xhtml -S 4gl;;
- *.a4c) exec /usr/bin/highlight -f -I -O xhtml -S a4c;;
- *.abp) exec /usr/bin/highlight -f -I -O xhtml -S abp;;
- *.ada) exec /usr/bin/highlight -f -I -O xhtml -S ada;;
- *.agda) exec /usr/bin/highlight -f -I -O xhtml -S agda;;
- *.ampl) exec /usr/bin/highlight -f -I -O xhtml -S ampl;;
- *.amtrix) exec /usr/bin/highlight -f -I -O xhtml -S amtrix;;
- *.applescript) exec /usr/bin/highlight -f -I -O xhtml -S applescript;;
- *.arc) exec /usr/bin/highlight -f -I -O xhtml -S arc;;
- *.arm) exec /usr/bin/highlight -f -I -O xhtml -S arm;;
- *.as) exec /usr/bin/highlight -f -I -O xhtml -S as;;
- *.asm) exec /usr/bin/highlight -f -I -O xhtml -S asm;;
- *.asp) exec /usr/bin/highlight -f -I -O xhtml -S asp;;
- *.aspect) exec /usr/bin/highlight -f -I -O xhtml -S aspect;;
- *.ats) exec /usr/bin/highlight -f -I -O xhtml -S ats;;
- *.au3) exec /usr/bin/highlight -f -I -O xhtml -S au3;;
- *.avenue) exec /usr/bin/highlight -f -I -O xhtml -S avenue;;
- *.awk) exec /usr/bin/highlight -f -I -O xhtml -S awk;;
- *.bat) exec /usr/bin/highlight -f -I -O xhtml -S bat;;
- *.bb) exec /usr/bin/highlight -f -I -O xhtml -S bb;;
- *.bib) exec /usr/bin/highlight -f -I -O xhtml -S bib;;
- *.bms) exec /usr/bin/highlight -f -I -O xhtml -S bms;;
- *.boo) exec /usr/bin/highlight -f -I -O xhtml -S boo;;
- *.c|*.h|*.cpp|*.C|*.H) exec /usr/bin/highlight -f -I -O xhtml -S c;;
- *.cb) exec /usr/bin/highlight -f -I -O xhtml -S cb;;
- *.cfc) exec /usr/bin/highlight -f -I -O xhtml -S cfc;;
- *.chl) exec /usr/bin/highlight -f -I -O xhtml -S chl;;
- *.clipper) exec /usr/bin/highlight -f -I -O xhtml -S clipper;;
- *.clojure) exec /usr/bin/highlight -f -I -O xhtml -S clojure;;
- *.clp) exec /usr/bin/highlight -f -I -O xhtml -S clp;;
- *.cob) exec /usr/bin/highlight -f -I -O xhtml -S cob;;
- *.cs) exec /usr/bin/highlight -f -I -O xhtml -S cs;;
- *.css) exec /usr/bin/highlight -f -I -O xhtml -S css;;
- *.d) exec /usr/bin/highlight -f -I -O xhtml -S d;;
- *.diff|*.patch) exec /usr/bin/highlight -f -I -O xhtml -S diff;;
- *.dot) exec /usr/bin/highlight -f -I -O xhtml -S dot;;
- *.dylan) exec /usr/bin/highlight -f -I -O xhtml -S dylan;;
- *.e) exec /usr/bin/highlight -f -I -O xhtml -S e;;
- *.erl) exec /usr/bin/highlight -f -I -O xhtml -S erl;;
- *.euphoria) exec /usr/bin/highlight -f -I -O xhtml -S euphoria;;
- *.exp) exec /usr/bin/highlight -f -I -O xhtml -S exp;;
- *.f77) exec /usr/bin/highlight -f -I -O xhtml -S f77;;
- *.f90) exec /usr/bin/highlight -f -I -O xhtml -S f90;;
- *.flx) exec /usr/bin/highlight -f -I -O xhtml -S flx;;
- *.frink) exec /usr/bin/highlight -f -I -O xhtml -S frink;;
- *.haskell|*.hs) exec /usr/bin/highlight -f -I -O xhtml -S haskell;;
- *.hcl) exec /usr/bin/highlight -f -I -O xhtml -S hcl;;
- *.httpd) exec /usr/bin/highlight -f -I -O xhtml -S httpd;;
- *.icn) exec /usr/bin/highlight -f -I -O xhtml -S icn;;
- *.idl) exec /usr/bin/highlight -f -I -O xhtml -S idl;;
- *.idlang) exec /usr/bin/highlight -f -I -O xhtml -S idlang;;
- *.ili) exec /usr/bin/highlight -f -I -O xhtml -S ili;;
- *.ini) exec /usr/bin/highlight -f -I -O xhtml -S ini;;
- *.inp) exec /usr/bin/highlight -f -I -O xhtml -S inp;;
- *.io) exec /usr/bin/highlight -f -I -O xhtml -S io;;
- *.iss) exec /usr/bin/highlight -f -I -O xhtml -S iss;;
- *.j) exec /usr/bin/highlight -f -I -O xhtml -S j;;
- *.java) exec /usr/bin/highlight -f -I -O xhtml -S java;;
- *.js) exec /usr/bin/highlight -f -I -O xhtml -S js;;
- *.jsp) exec /usr/bin/highlight -f -I -O xhtml -S jsp;;
- *.lbn) exec /usr/bin/highlight -f -I -O xhtml -S lbn;;
- *.ldif) exec /usr/bin/highlight -f -I -O xhtml -S ldif;;
- *.lgt) exec /usr/bin/highlight -f -I -O xhtml -S lgt;;
- *.lhs) exec /usr/bin/highlight -f -I -O xhtml -S lhs;;
- *.lisp) exec /usr/bin/highlight -f -I -O xhtml -S lisp;;
- *.lotos) exec /usr/bin/highlight -f -I -O xhtml -S lotos;;
- *.ls) exec /usr/bin/highlight -f -I -O xhtml -S ls;;
- *.lsl) exec /usr/bin/highlight -f -I -O xhtml -S lsl;;
- *.lua) exec /usr/bin/highlight -f -I -O xhtml -S lua;;
- *.ly) exec /usr/bin/highlight -f -I -O xhtml -S ly;;
- *.m) exec /usr/bin/highlight -f -I -O xhtml -S m;;
- *.make) exec /usr/bin/highlight -f -I -O xhtml -S make;;
- *.mel) exec /usr/bin/highlight -f -I -O xhtml -S mel;;
- *.mercury) exec /usr/bin/highlight -f -I -O xhtml -S mercury;;
- *.mib) exec /usr/bin/highlight -f -I -O xhtml -S mib;;
- *.miranda) exec /usr/bin/highlight -f -I -O xhtml -S miranda;;
- *.ml) exec /usr/bin/highlight -f -I -O xhtml -S ml;;
- *.mo) exec /usr/bin/highlight -f -I -O xhtml -S mo;;
- *.mod3) exec /usr/bin/highlight -f -I -O xhtml -S mod3;;
- *.mpl) exec /usr/bin/highlight -f -I -O xhtml -S mpl;;
- *.ms) exec /usr/bin/highlight -f -I -O xhtml -S ms;;
- *.mssql) exec /usr/bin/highlight -f -I -O xhtml -S mssql;;
- *.n) exec /usr/bin/highlight -f -I -O xhtml -S n;;
- *.nas) exec /usr/bin/highlight -f -I -O xhtml -S nas;;
- *.nice) exec /usr/bin/highlight -f -I -O xhtml -S nice;;
- *.nrx) exec /usr/bin/highlight -f -I -O xhtml -S nrx;;
- *.nsi) exec /usr/bin/highlight -f -I -O xhtml -S nsi;;
- *.nut) exec /usr/bin/highlight -f -I -O xhtml -S nut;;
- *.oberon) exec /usr/bin/highlight -f -I -O xhtml -S oberon;;
- *.objc) exec /usr/bin/highlight -f -I -O xhtml -S objc;;
- *.octave) exec /usr/bin/highlight -f -I -O xhtml -S octave;;
- *.oorexx) exec /usr/bin/highlight -f -I -O xhtml -S oorexx;;
- *.os) exec /usr/bin/highlight -f -I -O xhtml -S os;;
- *.oz) exec /usr/bin/highlight -f -I -O xhtml -S oz;;
- *.pas) exec /usr/bin/highlight -f -I -O xhtml -S pas;;
- *.php) exec /usr/bin/highlight -f -I -O xhtml -S php;;
- *.pike) exec /usr/bin/highlight -f -I -O xhtml -S pike;;
- *.pl|*.perl|*.pm) exec /usr/bin/highlight -f -I -O xhtml -S pl;;
- *.pl1) exec /usr/bin/highlight -f -I -O xhtml -S pl1;;
- *.pov) exec /usr/bin/highlight -f -I -O xhtml -S pov;;
- *.pro) exec /usr/bin/highlight -f -I -O xhtml -S pro;;
- *.progress) exec /usr/bin/highlight -f -I -O xhtml -S progress;;
- *.ps) exec /usr/bin/highlight -f -I -O xhtml -S ps;;
- *.ps1) exec /usr/bin/highlight -f -I -O xhtml -S ps1;;
- *.psl) exec /usr/bin/highlight -f -I -O xhtml -S psl;;
- *.py) exec /usr/bin/highlight -f -I -O xhtml -S py;;
- *.pyx) exec /usr/bin/highlight -f -I -O xhtml -S pyx;;
- *.q) exec /usr/bin/highlight -f -I -O xhtml -S q;;
- *.qmake) exec /usr/bin/highlight -f -I -O xhtml -S qmake;;
- *.qu) exec /usr/bin/highlight -f -I -O xhtml -S qu;;
- *.r) exec /usr/bin/highlight -f -I -O xhtml -S r;;
- *.rb) exec /usr/bin/highlight -f -I -O xhtml -S rb;;
- *.rebol) exec /usr/bin/highlight -f -I -O xhtml -S rebol;;
- *.rexx) exec /usr/bin/highlight -f -I -O xhtml -S rexx;;
- *.rnc) exec /usr/bin/highlight -f -I -O xhtml -S rnc;;
- *.s) exec /usr/bin/highlight -f -I -O xhtml -S s;;
- *.sas) exec /usr/bin/highlight -f -I -O xhtml -S sas;;
- *.sc) exec /usr/bin/highlight -f -I -O xhtml -S sc;;
- *.scala) exec /usr/bin/highlight -f -I -O xhtml -S scala;;
- *.scilab) exec /usr/bin/highlight -f -I -O xhtml -S scilab;;
- *.sh) exec /usr/bin/highlight -f -I -O xhtml -S sh;;
- *.sma) exec /usr/bin/highlight -f -I -O xhtml -S sma;;
- *.smalltalk) exec /usr/bin/highlight -f -I -O xhtml -S smalltalk;;
- *.sml) exec /usr/bin/highlight -f -I -O xhtml -S sml;;
- *.sno) exec /usr/bin/highlight -f -I -O xhtml -S sno;;
- *.spec) exec /usr/bin/highlight -f -I -O xhtml -S spec;;
- *.spn) exec /usr/bin/highlight -f -I -O xhtml -S spn;;
- *.sql) exec /usr/bin/highlight -f -I -O xhtml -S sql;;
- *.sybase) exec /usr/bin/highlight -f -I -O xhtml -S sybase;;
- *.tcl) exec /usr/bin/highlight -f -I -O xhtml -S tcl;;
- *.tcsh) exec /usr/bin/highlight -f -I -O xhtml -S tcsh;;
- *.test_re) exec /usr/bin/highlight -f -I -O xhtml -S test_re;;
- *.tex) exec /usr/bin/highlight -f -I -O xhtml -S tex;;
- *.ttcn3) exec /usr/bin/highlight -f -I -O xhtml -S ttcn3;;
- *.vala) exec /usr/bin/highlight -f -I -O xhtml -S vala;;
- *.vb) exec /usr/bin/highlight -f -I -O xhtml -S vb;;
- *.verilog) exec /usr/bin/highlight -f -I -O xhtml -S verilog;;
- *.vhd) exec /usr/bin/highlight -f -I -O xhtml -S vhd;;
- *.xml|*.htm|*.html) exec /usr/bin/highlight -f -I -O xhtml -S xml;;
- *.xpp) exec /usr/bin/highlight -f -I -O xhtml -S xpp;;
- *.y) exec /usr/bin/highlight -f -I -O xhtml -S y;;
- *.znn) exec /usr/bin/highlight -f -I -O xhtml -S znn;;
- *) exec /usr/bin/highlight -f -I -O xhtml -S txt;;
-esac
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php
index 5678bd3d1..8c197546c 100644
--- a/system/application/models/file_mod.php
+++ b/system/application/models/file_mod.php
@@ -190,7 +190,15 @@ class File_mod extends Model {
// count(file($file)); isn't
passthru('/usr/bin/perl -ne \'print "<a href=\"#n$.\" class=\"no\" id=\"n$.\" name=\"n$.\">$.</a>\n"\' '.escapeshellarg($file));
echo '</pre></td><td class="code"><pre>'."\n";
- echo shell_exec(FCPATH.'scripts/syntax-highlighting.sh '.escapeshellarg($filedata['filename']).'.'.escapeshellarg($mode).' < '.escapeshellarg($file));
+ if ($mode == 'txt') {
+ $fp = fopen($file,"r");
+ while (!feof($fp)) {
+ echo fread($fp,4096);
+ }
+ fclose($fp);
+ } else {
+ passthru('/usr/bin/pygmentize -l '.$mode.' -f html '.escapeshellarg($file));
+ }
echo '</pre>';
}
echo $this->load->view('file/html_footer', $data, true);