Sha256: 8de8ae8a14f2099a006cd4a42bac9a0846391cc689322af43c1414aaaa56e7d4

Contents?: true

Size: 590 Bytes

Versions: 10

Compression:

Stored size: 590 Bytes

Contents

module Filters
  module PreFilter
    def format_helper(text)
      prefix = '<p'

      text.gsub /\n?``` helper(.+?)```/m do |block|
        block.gsub! /^``` helper/, ''
        block.gsub! /^```$/, ''

        header = ''
        block.gsub! /^#### (.+?)$/ do
          header = $1.strip
          ''
        end

        content = block.strip
        content = "<p>#{content}</p>" unless content[0, prefix.length] == prefix
        content = "<div class='helper'><h4 class='header'><a href='#'>#{header}</a></h4><div class='content'>#{content}</div></div>"
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
extended-markdown-filter-0.7.0 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.10 lib/filters/pre/helper.rb
extended-markdown-filter-0.6.0 lib/filters/pre/helper.rb
extended-markdown-filter-0.5.1 lib/filters/pre/helper.rb
extended-markdown-filter-0.5.0 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.9 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.8 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.7 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.6 lib/filters/pre/helper.rb
extended-markdown-filter-0.4.5 lib/filters/pre/helper.rb