Sha256: 18584dec385749876abf69035c44d1247efa227484c340c4c88b3948faab1bc0

Contents?: true

Size: 542 Bytes

Versions: 5

Compression:

Stored size: 542 Bytes

Contents

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

        block
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
extended-markdown-filter-0.4.10 lib/filters/pre/command-line.rb
extended-markdown-filter-0.5.1 lib/filters/pre/command-line.rb
extended-markdown-filter-0.5.0 lib/filters/pre/command-line.rb
extended-markdown-filter-0.4.9 lib/filters/pre/command-line.rb
extended-markdown-filter-0.4.8 lib/filters/pre/command-line.rb