Skip to content

Commit 358d02a

Browse files
committed
centralized pygments aliases into pygments_code.rb. Added alias for .ru (ruby), which sort of fixes #108
1 parent 596ec87 commit 358d02a

3 files changed

Lines changed: 4 additions & 6 deletions

File tree

plugins/code_block.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ def render(context)
7777
source += @caption if @caption
7878
source = context['pygments_prefix'] + source if context['pygments_prefix']
7979
if @filetype
80-
@filetype = 'objc' if @filetype == 'm'
81-
@filetype = 'perl' if @filetype == 'pl'
82-
@filetype = 'yaml' if @filetype == 'yml'
8380
source += " #{highlight(code, @filetype)}</figure></div>"
8481
else
8582
source += "#{tableize_code(code.lstrip.rstrip.gsub(/</,'&lt;'))}</figure></div>"

plugins/include_code.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ def render(context)
5353
Dir.chdir(code_path) do
5454
code = file.read
5555
@filetype = file.extname.sub('.','')
56-
@filetype = 'objc' if @filetype == 'm'
57-
@filetype = 'perl' if @filetype == 'pl'
58-
@filetype = 'yaml' if @filetype == 'yml'
5956
title = @title ? "#{@title} (#{file.basename})" : file.basename
6057
url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
6158
source = "<div><figure role=code><figcaption><span>#{title}</span> <a href='#{url}'>download</a></figcaption>\n"

plugins/pygments_code.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77

88
module HighlightCode
99
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'
1014
str = pygments(str, lang).match(/<pre>(.+)<\/pre>/m)[1].to_s.gsub(/ *$/, '') #strip out divs <div class="highlight">
1115
tableize_code(str, lang)
1216
end

0 commit comments

Comments
 (0)