ruhoh/ruhoh.rb — pull request #170 by Stebalien (2013-05-29 06:35:39+00:00)
Title: Better summary generation

Yet another pull request (sorry). Overall, this makes the summary generation smarter.

This patch improves the summary generation by:
- Ensuring that elements are not truncated.
- Working properly with any content format (not just markdown).
- Allowing the user to manually indicate the summary (by wrapping it in an element with the `summary` class).
- Allowing the user to truncate the summary at headers (by setting `summary_stop_at_header`) .

The new summary generation function works as follows:
- If a summary element (`...`) is specified
in the content, return it.
- If the `summary_lines` option is greater than 0, truncate after the first complete element where the number of summary lines is greater than `summary_lines`.
- If the `summary_stop_at_header` option (new) is true, stop before the first header that
is after some non-empty content. That is, include any headers at the
top of a post but not subsequent ones.
- Finally, if any non-whitespace text was truncated, the `ellipsis`
class is added to the summary element.

It also lets the user override the summary settings on a per-post basis.

Questions(ish):
1. Should the summary options be broken into their own section?
2. Should there be options for changing the summary and ellipsis class names? Should there be an option for changing the summary wrapper tag (to something other than `span`)?
3. Should there be a way to manually set the summary content in the yaml header?
4. Code quality?
5. Overkill?