OSDN Git Service

add pretyprint master
authormasahino <masahino@gmail.com>
Sun, 19 May 2013 11:51:12 +0000 (20:51 +0900)
committermasahino <masahino@gmail.com>
Sun, 19 May 2013 11:51:12 +0000 (20:51 +0900)
lib/ldblogwriter/parser.rb

index 3168892..3598795 100644 (file)
@@ -101,7 +101,7 @@ module LDBlogWriter
       end
       buf
     end
-
+   
     def syntax_highlight(lines, lang)
       require 'syntax/convertors/html'
       convertor = Syntax::Convertors::HTML.for_syntax lang
@@ -113,6 +113,9 @@ module LDBlogWriter
       if lines.first =~ /\Ahighlight\((.*)\)/
         lines.shift
         syntax_highlight(lines, $1)
+      elsif lines.first =~ /\A#prettyprint/
+        lines.shift
+        ["<pre class=\"prettyprint\">", lines.join("\n"), "</pre>"]
       else
         ["<pre>", lines.map {|line| escape_html(line) }.join("\n"),
         '</pre>']