Sha256: 243734eccaffb199402a44bc2e2effd9d6b01f6651479d9d30c4616f2508a7ff
Contents?: true
Size: 1.05 KB
Versions: 1
Compression:
Stored size: 1.05 KB
Contents
require "pathname" require "dionysus/redcarpet" require "active_support/core_ext/object/blank" module Dionysus module Redcarpet # This is an extension to Redcarpet that allows you to include a file, preprocessor. # # @example README.md # = This is my README # <<< LICENSE.txt module Includes extend ActiveSupport::Concern included do preprocess_line do |renderer, line| if m = line.match(LINE_DIRECTIVE_REGEXP) path = Pathname.new(m[1]) if path.file? newlines = path.readlines newlines.collect! {|ln| ln.chomp} newlines.shift while(newlines.first.blank?) newlines.pop while(newlines.last.blank?) line = newlines.join("\n") line = renderer.preprocess(line) else warn "[WARNING] Cannot find path %s to include"%[path.to_s] end end line end end end end end Redcarpet::Render::HTML.send(:include, Dionysus::Redcarpet::Includes)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dionysus-2.2.0.0.pre1 | lib/dionysus/redcarpet/includes.rb |