class Daimon::Markdown::Redcarpet::HTMLRenderer

Public Class Methods

new(extensions = {}) click to toggle source
Calls superclass method
# File lib/daimon/markdown/redcarpet/html_renderer.rb, line 10
def initialize(extensions = {})
  super
  @plugins = []
end

Public Instance Methods

postprocess(full_document) click to toggle source
# File lib/daimon/markdown/redcarpet/html_renderer.rb, line 29
def postprocess(full_document)
  return full_document if @plugins.empty?
  document = ""
  scanner = StringScanner.new(full_document)
  loop do
    break if scanner.eos?
    if scanner.match?(/{{.+?}}/m)
      document << @plugins.shift
      scanner.pos += scanner.matched_size
    else
      document << scanner.getch
    end
  end
  document
end
preprocess(full_document) click to toggle source
# File lib/daimon/markdown/redcarpet/html_renderer.rb, line 15
def preprocess(full_document)
  scanner = StringScanner.new(full_document)
  loop do
    break if scanner.eos?
    if scanner.match?(/{{.+?}}/m)
      @plugins << scanner.matched
      scanner.pos += scanner.matched_size
    else
      scanner.getch
    end
  end
  full_document
end