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

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

Issue 138823002: Draft of new codelab for review (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: integrated seths' comments Created 6 years, 11 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
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 18 matching lines...) Expand all
29 def render(context) 29 def render(context)
30 # out = '<pre class="prettyprint linenums' 30 # out = '<pre class="prettyprint linenums'
31 out = '<pre class="prettyprint' 31 out = '<pre class="prettyprint'
32 unless @lang.nil? 32 unless @lang.nil?
33 out += ' lang-' + @lang 33 out += ' lang-' + @lang
34 end 34 end
35 out += '">' 35 out += '">'
36 36
37 contents = super.strip 37 contents = super.strip
38 contents = CGI::escapeHTML(contents) 38 contents = CGI::escapeHTML(contents)
39
40 contents.gsub!('[[strike]]', '<code class="nocode strike">')
41 contents.gsub!('[[/strike]]', '</code>')
42
39 contents.gsub!('[[highlight]]', '<code class="nocode highlight">') 43 contents.gsub!('[[highlight]]', '<code class="nocode highlight">')
40 contents.gsub!('[[/highlight]]', '</code>') 44 contents.gsub!('[[/highlight]]', '</code>')
41 45
42 out += contents + "</pre>" 46 out += contents + "</pre>"
43 end 47 end
44 48
45 end 49 end
46 end 50 end
47 51
48 Liquid::Template.register_tag('prettify', Prettify::Tag) 52 Liquid::Template.register_tag('prettify', Prettify::Tag)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698