| 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 18 matching lines...) Expand all Loading... |
| 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) |
| OLD | NEW |