Browse code

centralized pygments aliases into pygments_code.rb. Added alias for .ru (ruby), which sort of fixes #108

Brandon Mathis authored on 20/08/2011 at 22:39:00
Showing 3 changed files
... ...
@@ -77,9 +77,6 @@ module Jekyll
77 77
       source += @caption if @caption
78 78
       source = context['pygments_prefix'] + source if context['pygments_prefix']
79 79
       if @filetype
80
-        @filetype = 'objc' if @filetype == 'm'
81
-        @filetype = 'perl' if @filetype == 'pl'
82
-        @filetype = 'yaml' if @filetype == 'yml'
83 80
         source += " #{highlight(code, @filetype)}</figure></div>"
84 81
       else
85 82
         source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'&lt;'))}</figure></div>"
... ...
@@ -53,9 +53,6 @@ module Jekyll
53 53
       Dir.chdir(code_path) do
54 54
         code = file.read
55 55
         @filetype = file.extname.sub('.','')
56
-        @filetype = 'objc' if @filetype == 'm'
57
-        @filetype = 'perl' if @filetype == 'pl'
58
-        @filetype = 'yaml' if @filetype == 'yml'
59 56
         title = @title ? "#{@title} (#{file.basename})" : file.basename
60 57
         url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
61 58
         source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"
... ...
@@ -7,6 +7,10 @@ FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
7 7
 
8 8
 module HighlightCode
9 9
   def highlight(str, lang)
10
+    lang = 'ruby' if lang == 'ru'
11
+    lang = 'objc' if lang == 'm'
12
+    lang = 'perl' if lang == 'pl'
13
+    lang = 'yaml' if lang == 'yml'
10 14
     str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight">
11 15
     tableize_code(str, lang)
12 16
   end