Sha256: 5ec8325866f7ca53a53a608d0ce2d9408e067e6b8570e286f9e529eb59cdae7c

Contents?: true

Size: 523 Bytes

Versions: 4

Compression:

Stored size: 523 Bytes

Contents

module Filters
  module PreFilter
    def format_command_line(text)
      text.gsub /\n?``` command-line(.+?)```/m do |block|
        block.gsub! /^``` command-line/, '<pre class="command-line">'
        block.gsub! /^```$/, "</pre>\n"
        block.gsub!(/^\$ (.+)$/) { %(<span class="command">#{$1.rstrip}</span>) }
        block.gsub!(/^(\# .+)$/) { %(<span class="comment">#{$1.rstrip}</span>) }
        block.gsub!(/^> (.+)$/) { %(<span class="output">#{$1.rstrip}</span>) }

        block
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
extended-markdown-filter-0.4.6 lib/filters/pre/command-line.rb
extended-markdown-filter-0.4.5 lib/filters/pre/command-line.rb
extended-markdown-filter-0.4.4 lib/filters/pre/command-line.rb
extended-markdown-filter-0.4.3 lib/filters/pre/command-line.rb