Browse code

updated syntax highlighting support for perl and objective c in code_block and include_code plugins

Brandon Mathis authored on 26/07/2011 at 00:34:52
Showing 3 changed files
... ...
@@ -126,9 +126,10 @@ p code {
126 126
   .n      { color: $blue !important; }
127 127
   .na     { color: $blue !important; }                                          /* Name.Attribute */
128 128
   .nb     { color: $green !important; }                                          /* Name.Builtin */
129
-  //.nc     { color: #445588; font-weight: bold }                       /* Name.Class */
129
+  .nc     { color: $magenta !important;}                                                   /* Name.Class */
130 130
   .no     { color: $yellow !important; }                                          /* Name.Constant */
131 131
   //.ni     { color: #800080 }                                          /* Name.Entity */
132
+  .nl     { color: $green !important; }
132 133
   .ne     { color: $blue !important; font-weight: bold !important; }                       /* Name.Exception */
133 134
   .nf     { color: $blue !important; font-weight: bold !important; }                       /* Name.Function */
134 135
   .nn     { color: $yellow !important; }                                          /* Name.Namespace */
... ...
@@ -215,3 +216,4 @@ figure[role=code] {
215 215
   padding-left: 3em;
216 216
 }
217 217
 
218
+
... ...
@@ -73,6 +73,8 @@ module Jekyll
73 73
       source = "<div><figure role=code>"
74 74
       source += @caption if @caption
75 75
       if @filetype
76
+        @filetype = 'objc' if @filetype == 'm'
77
+        @filetype = 'perl' if @filetype == 'pl'
76 78
         source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>"
77 79
       else
78 80
         source += "<pre><code>" + code.lstrip.rstrip.gsub(/</,'&lt;') + "</code></pre></figure></div>"
... ...
@@ -50,11 +50,13 @@ module Jekyll
50 50
 
51 51
       Dir.chdir(code_path) do
52 52
         code = file.read
53
-        file_type = file.extname
53
+        @filetype = file.extname
54
+        @filetype = 'objc' if @filetype == 'm'
55
+        @filetype = 'perl' if @filetype == 'pl'
54 56
         title = @title ? "#{@title} (#{file.basename})" : file.basename
55 57
         url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
56 58
         source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"
57
-        source += "{% highlight #{file_type} %}\n" + code + "\n{% endhighlight %}</figure></div>"
59
+        source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>"
58 60
         partial = Liquid::Template.parse(source)
59 61
         context.stack do
60 62
           partial.render(context)