gma/nesta — Issue #84: Parse heading with appropriate parser after extracting it
Author: gryzzly
Created: 2011-12-19 00:09:42+00:00
State: open

If I have page with the following content:

Date: 19 December 2011

# JavaScript inheritance and `prototype` object

Here goes content …

The `page.heading` should return `"JavaScript inheritance and prototype object"`. So that it will align with actual contents of your `h1` on the page.
There is `page.title` that is supposed to hold plain text version of the page's title.

I've tried to mess with the following code, but markup is a private property, so I can override it in `app.rb`.

class Page < FileModel
def heading
regex = case @format
when :mdown
/^#\s*(.*?)(\s*#+|$)/
when :haml
/^\s*%h1\s+(.*)/
when :textile
/^\s*h1\.\s+(.*)/
end
markup =~ regex
Regexp.last_match(1)
end
end

Thanks!