Skip to content

Commit 727617f

Browse files
committed
review-ext.rbにてHTMLBuilderでコード例を出力する際にclassに言語コードを出力するように変更
1 parent 4bbdf75 commit 727617f

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

articles/.gitignore

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,3 @@
99
*.epub
1010

1111
*.css
12-
!epub.css
13-
14-
# switch by grunt task
15-
review-ext.rb
16-
layouts/layout.html.erb

articles/review-ext.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# encoding: utf-8
2+
3+
module ReVIEW
4+
class HTMLBuilder
5+
def list_body(id, lines, lang)
6+
id ||= ''
7+
classNames = ["list"]
8+
lang ||= File.extname(id).gsub(/\./, '')
9+
if lang != ''
10+
classNames.push("language-#{lang}")
11+
end
12+
print %Q[<pre class="#{classNames.join(" ")}">]
13+
body = lines.inject(''){|i, j| i + detab(j) + "\n"}
14+
lexer = lang || File.extname(id).gsub(/\./, '')
15+
puts highlight(:body => body, :lexer => lexer, :format => 'html')
16+
puts '</pre>'
17+
end
18+
end
19+
end

0 commit comments

Comments
 (0)