patch

use pygmentize instead of coderay patch - Youssef Abou-Kewik, 2008-07-15 20:54

Download (4.67 KB)

 
1
Index: app/helpers/application_helper.rb
2
===================================================================
3
--- app/helpers/application_helper.rb	(revision 1669)
4
+++ app/helpers/application_helper.rb	(working copy)
5
@@ -107,9 +107,19 @@
6
     l(:actionview_datehelper_select_month_names).split(',')[month-1]
7
   end
8
 
9
+  def escape_shell_arg(str)
10
+    "'%s'" % str.to_s.gsub("'","'\\\\''")
11
+  end
12
+
13
+  def transform_code_blocks(code, lang)
14
+    code = `echo #{escape_shell_arg(code)} | pygmentize -f html -l #{escape_shell_arg(lang)}`
15
+    "%s" % code
16
+  end
17
+
18
+
19
   def syntax_highlight(name, content)
20
     type = CodeRay::FileType[name]
21
-    type ? CodeRay.scan(content, type).html : h(content)
22
+    type ? transform_code_blocks(content, type)  : h(content)
23
   end
24
   
25
   def to_path_param(path)
26
Index: vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb
27
===================================================================
28
--- vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb	(revision 1669)
29
+++ vendor/plugins/coderay-0.7.6.227/lib/coderay/helpers/file_type.rb	(working copy)
30
@@ -93,6 +93,8 @@
31
     'php3' => :php,
32
     'php4' => :php,
33
     'php5' => :php,
34
+    'py' => :python,
35
+    'svg' => :xml,
36
     'xhtml' => :xhtml,
37
     'raydebug' => :debug,
38
     'rhtml' => :rhtml,
39
Index: public/stylesheets/scm.css
40
===================================================================
41
--- public/stylesheets/scm.css	(revision 1669)
42
+++ public/stylesheets/scm.css	(working copy)
43
@@ -150,3 +150,63 @@
44
 .CodeRay .ty { color:#339; font-weight:bold }
45
 .CodeRay .v  { color:#036 }
46
 .CodeRay .xt { color:#444 }
47
+
48
+.c { color: #408080; font-style: italic } /* Comment */
49
+.err { border: 1px solid #FF0000 } /* Error */
50
+.k { color: #008000; font-weight: bold } /* Keyword */
51
+.o { color: #666666 } /* Operator */
52
+.cm { color: #408080; font-style: italic } /* Comment.Multiline */
53
+.cp { color: #BC7A00 } /* Comment.Preproc */
54
+.c1 { color: #408080; font-style: italic } /* Comment.Single */
55
+.cs { color: #408080; font-style: italic } /* Comment.Special */
56
+.gd { color: #A00000 } /* Generic.Deleted */
57
+.ge { font-style: italic } /* Generic.Emph */
58
+.gr { color: #FF0000 } /* Generic.Error */
59
+.gh { color: #000080; font-weight: bold } /* Generic.Heading */
60
+.gi { color: #00A000 } /* Generic.Inserted */
61
+.go { color: #808080 } /* Generic.Output */
62
+.gp { color: #000080; font-weight: bold } /* Generic.Prompt */
63
+.gs { font-weight: bold } /* Generic.Strong */
64
+.gu { color: #800080; font-weight: bold } /* Generic.Subheading */
65
+.gt { color: #0040D0 } /* Generic.Traceback */
66
+.kc { color: #008000; font-weight: bold } /* Keyword.Constant */
67
+.kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
68
+.kp { color: #008000 } /* Keyword.Pseudo */
69
+.kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
70
+.kt { color: #B00040 } /* Keyword.Type */
71
+.m { color: #666666 } /* Literal.Number */
72
+.s { color: #BA2121 } /* Literal.String */
73
+.na { color: #7D9029 } /* Name.Attribute */
74
+.nb { color: #008000 } /* Name.Builtin */
75
+.nc { color: #0000FF; font-weight: bold } /* Name.Class */
76
+.no { color: #880000 } /* Name.Constant */
77
+.nd { color: #AA22FF } /* Name.Decorator */
78
+.ni { color: #999999; font-weight: bold } /* Name.Entity */
79
+.ne { color: #D2413A; font-weight: bold } /* Name.Exception */
80
+.nf { color: #0000FF } /* Name.Function */
81
+.nl { color: #A0A000 } /* Name.Label */
82
+.nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
83
+.nt { color: #008000; font-weight: bold } /* Name.Tag */
84
+.nv { color: #19177C } /* Name.Variable */
85
+.ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
86
+.w { color: #bbbbbb } /* Text.Whitespace */
87
+.mf { color: #666666 } /* Literal.Number.Float */
88
+.mh { color: #666666 } /* Literal.Number.Hex */
89
+.mi { color: #666666 } /* Literal.Number.Integer */
90
+.mo { color: #666666 } /* Literal.Number.Oct */
91
+.sb { color: #BA2121 } /* Literal.String.Backtick */
92
+.sc { color: #BA2121 } /* Literal.String.Char */
93
+.sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
94
+.s2 { color: #BA2121 } /* Literal.String.Double */
95
+.se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
96
+.sh { color: #BA2121 } /* Literal.String.Heredoc */
97
+.si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
98
+.sx { color: #008000 } /* Literal.String.Other */
99
+.sr { color: #BB6688 } /* Literal.String.Regex */
100
+.s1 { color: #BA2121 } /* Literal.String.Single */
101
+.ss { color: #19177C } /* Literal.String.Symbol */
102
+.bp { color: #008000 } /* Name.Builtin.Pseudo */
103
+.vc { color: #19177C } /* Name.Variable.Class */
104
+.vg { color: #19177C } /* Name.Variable.Global */
105
+.vi { color: #19177C } /* Name.Variable.Instance */
106
+.il { color: #666666 } /* Literal.Number.Integer.Long */