lib/amber/static_page/filesystem.rb
def parse_headers(content_file)
      headers = []
      para1 = []
      para2 = []
      file_type = type_from_path(content_file)

      File.open(content_file, :encoding => 'UTF-8') do |f|
        while (line = f.gets) =~ /^(- |)@\w/
          if line !~ /^-/
            line = '- ' + line
          end
          headers << line
        end
        # eat empty lines
        while line = f.gets
          break unless line =~ /^\s*$/
        end
        # grab first two paragraphs
        para1 << line
        while line = f.gets
          break if line =~ /^\s*$/
          para1 << line
        end
        while line = f.gets
          break if line =~ /^\s*$/
          para2 << line
        end
      end

      headers = headers.join
      para1 = para1.join
      para2 = para2.join
      excerpt = ""

      # pick the first non-heading paragraph.
      # this is stupid, and chokes on nested headings.
      # but is also cheap and fast :)
      if file_type == :textile
        if para1 =~ /^h[1-5]\. /
          excerpt = para2
        else
          excerpt = para1
        end
      elsif file_type == :markdown
        if para1 =~ /^#+ / || para1 =~ /^(===+|---+)\s*$/m
          excerpt = para2
        else
          excerpt = para1
        end
      end
      return [headers, excerpt]
    end
def parse_headers(content_file)
      headers = []
      para1 = []
      para2 = []
      file_type = type_from_path(content_file)

      File.open(content_file, :encoding => 'UTF-8') do |f|
        while (line = f.gets) =~ /^(- |)@\w/
          if line !~ /^-/
            line = '- ' + line
          end
          headers << line
        end
        # eat empty lines
        while line = f.gets
          break unless line =~ /^\s*$/
        end
        # grab first two paragraphs
        para1 << line
        while line = f.gets
          break if line =~ /^\s*$/
          para1 << line
        end
        while line = f.gets
          break if line =~ /^\s*$/
          para2 << line
        end
      end

      headers = headers.join
      para1 = para1.join
      para2 = para2.join
      excerpt = ""

      # pick the first non-heading paragraph.
      # this is stupid, and chokes on nested headings.
      # but is also cheap and fast :)
      if file_type == :textile
        if para1 =~ /^h[1-5]\. /
          excerpt = para2
        else
          excerpt = para1
        end
      elsif file_type == :markdown
        if para1 =~ /^#+ / || para1 =~ /^(===+|---+)\s*$/m
          excerpt = para2
        else
          excerpt = para1
        end
      end
      return [headers, excerpt]
    end
parses a content_file's property headers and tries to extract the
 first paragraph.