# -*- coding: utf-8 -*- # # coderay.rb - easy syntax highlighting for selected languages # refer to the URL below. # http://coderay.rubychan.de/ # # Copyright (C) 2013, tamoot # You can redistribute it and/or modify it under GPL2. # require 'cgi' require 'erb' require 'coderay' @coderay_default_css ||= ::CodeRay::Encoders[:html]::CSS.new(:default).stylesheet def coderay(lang, text, options = {}) html = ::CodeRay.scan(text, lang).html(:line_numbers => :inline, :bold_every => false, :line_number_anchors => false) %Q|
#{html}
| end add_header_proc do coderay_css = '' if @conf['coderay.css.url'] && @conf['coderay.css.url'].size > 0 coderay_css = %Q|| else coderay_css = <<-STYLE STYLE end coderay_css end add_conf_proc( 'coderay', 'CodeRay' ) do if @mode == 'saveconf' then @conf['coderay.css.url'] = @cgi.params['coderay.css.url'][0] end coderay_conf = <<-HTML

custom style

The stylesheet path is used instead of CodeRay default.

Path:

   sample:
   #{CGI::escape_html('')}
   

Print default stylesheet of CodeRay

1. The coderay command installed along with the CodeRay gem can print out a stylesheet for you.

   bundle exec coderay stylesheet > /your/tdiary/path/coderay.css
   

2. Edit your stylesheet and modify permissions.

HTML coderay_conf end # Local Variables: # mode: ruby # indent-tabs-mode: t # tab-width: 3 # ruby-indent-level: 3 # End: # vim: ts=3