Sha256: 07a5bacda2b857e91573c164dc235434ad532e8a91e276a72c38cd5da07ca26c

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

# If Haml is around, define a :code filter that can be used to more conveniently output highlighted code.
if defined? Haml
  module Haml
    module Filters
      module Code
        include Base

        def render(code)
          code = code.rstrip
          code = code.encode(Encoding::UTF_8)

          # Allow language to be specified via a special comment like:
          #  # lang: ruby
          if code.lines.first =~ /\A\s*#\s*lang:\s*(\w+)$/
              language = $1
            code = code.lines.to_a[1..-1].join # Strip first line
          end

          Middleman::Syntax::Highlighter.highlight(code, language)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-syntax-3.3.0 lib/middleman-syntax/haml_monkey_patch.rb