Skip to content

Commit 20764e3

Browse files
committed
updated syntax highlighting support for perl and objective c in code_block and include_code plugins
1 parent d10ba20 commit 20764e3

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

.themes/classic/sass/partials/_syntax.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,10 @@ p code {
126126
.n { color: $blue !important; }
127127
.na { color: $blue !important; } /* Name.Attribute */
128128
.nb { color: $green !important; } /* Name.Builtin */
129-
//.nc { color: #445588; font-weight: bold } /* Name.Class */
129+
.nc { color: $magenta !important;} /* Name.Class */
130130
.no { color: $yellow !important; } /* Name.Constant */
131131
//.ni { color: #800080 } /* Name.Entity */
132+
.nl { color: $green !important; }
132133
.ne { color: $blue !important; font-weight: bold !important; } /* Name.Exception */
133134
.nf { color: $blue !important; font-weight: bold !important; } /* Name.Function */
134135
.nn { color: $yellow !important; } /* Name.Namespace */
@@ -215,3 +216,4 @@ figure[role=code] {
215216
padding-left: 3em;
216217
}
217218

219+

plugins/code_block.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def render(context)
7373
source = "<div><figure role=code>"
7474
source += @caption if @caption
7575
if @filetype
76+
@filetype = 'objc' if @filetype == 'm'
77+
@filetype = 'perl' if @filetype == 'pl'
7678
source += "{% highlight #{@filetype} %}\n" + code + "\n{% endhighlight %}</figure></div>"
7779
else
7880
source += "<pre><code>" + code.lstrip.rstrip.gsub(/</,'&lt;') + "</code></pre></figure></div>"

plugins/include_code.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ def render(context)
5050

5151
Dir.chdir(code_path) do
5252
code = file.read
53-
file_type = file.extname
53+
@filetype = file.extname
54+
@filetype = 'objc' if @filetype == 'm'
55+
@filetype = 'perl' if @filetype == 'pl'
5456
title = @title ? "#{@title} (#{file.basename})" : file.basename
5557
url = "#{context.registers[:site].config['url']}/#{code_dir}/#{@file}"
5658
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>"
5860
partial = Liquid::Template.parse(source)
5961
context.stack do
6062
partial.render(context)

0 commit comments

Comments
 (0)