| OLD | NEW |
| 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 Loading... |
| 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) |
| OLD | NEW |