class Jekyll::Joule::Page

Constants

WHITESPACE_REGEXP

Public Instance Methods

reparse(content = "") click to toggle source
# File lib/jekyll/joule/page.rb, line 18
def reparse(content = "")
  content = unindent(content)
  if content =~ Jekyll::Document::YAML_FRONT_MATTER_REGEXP
    self.content = %Q[\n#{$POSTMATCH.strip}\n]
    self.data = SafeYAML.load(Regexp.last_match(1))
  else
    self.content = content
    self.data = Hash.new
  end

  return self.content
end
unindent(content) click to toggle source
# File lib/jekyll/joule/page.rb, line 8
def unindent(content)
  content.gsub!(/\A^\s*\n/, "")
  if content =~ WHITESPACE_REGEXP
    indentation = Regexp.last_match(0).length
    content.gsub!(/^\ {#{indentation}}/, "")
  end

  return content
end