A few code snippets using CodeRay filters for syntax highlighting.
lang=”ruby”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
require 'coderay' class CodeMacro < FilteredColumn::Macros::Base def self.filter(attributes, inner_text = '', text = '') lang = attributes.delete(:lang) attributes[:line_numbers] = :table unless attributes.has_key?(:line_numbers) attributes.each do |key, value| attributes[key] = value == 'nil' ? nil : value.to_sym rescue nil end begin CodeRay.scan(inner_text, lang.to_sym).html(attributes) rescue ArgumentError CodeRay.scan(inner_text, lang.to_sym).html(:line_numbers => :table) rescue unless lang.blank? RAILS_DEFAULT_LOGGER.warn "CodeRay Error: #{$!.message}" RAILS_DEFAULT_LOGGER.debug $!.backtrace.join("n") end "<pre><code>#{inner_text}</code></pre>" end end end |
lang=”javascript”
1 2 3 4 5 6 7 |
fixIEOverlapping: function() { Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); this.iefix.style.zIndex = 1; this.update.style.zIndex = 2; Element.show(this.iefix); }, |
Good morning!