class MarkdownIncluder::Heading

Attributes

level[RW]
title[RW]

Public Class Methods

new(level, title) click to toggle source
# File lib/markdown_helper/markdown_includer.rb, line 216
def initialize(level, title)
  self.level = level
  self.title = title
end
parse(line) click to toggle source
# File lib/markdown_helper/markdown_includer.rb, line 221
def self.parse(line)
  # Four leading spaces not allowed (but three are allowed).
  return nil if line.start_with?(' ' * 4)
  stripped_line = line.sub(/^ */, '')
  # Now must begin with hash marks and space.
  return nil unless stripped_line.match(/^#+ /)
  hash_marks, title = stripped_line.split(' ', 2)
  level = hash_marks.size
  # Seventh level heading not allowed.
  return nil if level > 6
  self.new(level, title)
end

Public Instance Methods