Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: src/site/_plugins/prettify.rb

Issue 19291003: basic code highlighting for our docs (Closed) Base URL: git@github.com:dart-lang/dartlang.org.git@master
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/site/css/style.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 4
5 require 'cgi' 5 require 'cgi'
6 6
7 module Prettify 7 module Prettify
8 8
9 # Wraps code with tags for Prettify. 9 # Wraps code with tags for Prettify.
10 # 10 #
(...skipping 13 matching lines...) Expand all
24 if markup =~ Syntax 24 if markup =~ Syntax
25 @lang = $1 25 @lang = $1
26 end 26 end
27 end 27 end
28 28
29 def render(context) 29 def render(context)
30 out = '<pre class="prettyprint' 30 out = '<pre class="prettyprint'
31 unless @lang.nil? 31 unless @lang.nil?
32 out += ' lang-' + @lang 32 out += ' lang-' + @lang
33 end 33 end
34 out += '">' + CGI::escapeHTML(super) + "</pre>" 34 out += '">'
35
36 contents = super.strip
37 contents = CGI::escapeHTML(contents)
38 contents.gsub!('[[highlight]]', '<code class="nocode highlight">')
39 contents.gsub!('[[/highlight]]', '</code>')
40
41 out += contents + "</pre>"
35 end 42 end
36 43
37 end 44 end
38 end 45 end
39 46
40 Liquid::Template.register_tag('prettify', Prettify::Tag) 47 Liquid::Template.register_tag('prettify', Prettify::Tag)
OLDNEW
« no previous file with comments | « no previous file | src/site/css/style.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698