middleman / middleman-blog

Blog Engine Extension for Middleman
https://middlemanapp.com
MIT License
326 stars 179 forks source link

Blog summaries don't properly render content #80

Closed bhollis closed 11 years ago

bhollis commented 12 years ago

My and @tdreyno's initial attempt at producing blog summaries didn't work because it would split tags, sometimes causing invalid HTML. @rumpuslabs fixed it to truncate the template, then render, which sounds better, except:

The correct solution would be to use Nokogiri to parse the rendered content, then iterate through the nodes, adding whole elements until the total text length got past a certain point. This would necessitate adding a dependency on nokogiri to middleman-blog. Alternately, we could just drop the summary-based-on-length feature and require people place a break point in their blog posts.

eostrom commented 11 years ago

There's at least one gem out there that tries to truncate HTML cleanly using Nokogiri. Might be worth a look: https://github.com/nono/HTML-Truncator

stevenringo commented 11 years ago

I am experiencing this problem and would prefer just to insert my own summary marker when required.

Browsing the code it looks like blog.summary_length cannot be disabled. I am using 100_000 as a workaround. Happy to submit a pull request to fix this. Just need to decide how it should be configured:

bhollis commented 11 years ago

Yeah, this needs work. Certainly having the ability to just turn it off would help.

bhollis commented 11 years ago

Fixed in #100.