Jonathan Martin
Archive for May 2011
-
ENGL 1102: Reading Practices and Comprehensive Depth
~ by Jonathan Martin
I wrote this essay last year as an ENGL 1102 assignment, and as it seems a waste not to put my old essays to some use, I will be starting a series that pulls from my more interesting assignments. Not too much red ink please, or I may relapse into essay revision stress disorder!
Reading Practices and Their Relationship to Comprehensive Depth
Inevitably, the method or procedure through which reading comprehension is accomplished directly affects its retention and inward understanding. Additionally, depending on the context, the audience may strive for particular excellence in certain aspects while ignoring others. Obviously the purpose of reading will consequently determine the manner in which the composition is approached and noted. Multiple generic instances of this variability present themselves as prime candidates for observation.
-
Ruby Extension: HTML Truncation
~ by Jonathan Martin
Another tip (err hurdle) I came across during the production of this blog — truncating an HTML string. Easy, right?
It seems simple enough: shorten some basic text content from a long entry. It’s extremely popular in blogs, catalogs, portfolios, etc. and with good reason — the average browser wants to find content through screening, not mass scrolling.
But a good trimmer must keep a few things in mind.
- Don’t split words
- Recognize/respect HTML tags
- Parse HTML according to standards
These add up to some pretty terse requirements once you actually get to coding. First, unless we want to manually parse HTML, we’ll have to use some standards based parser and loop through all the elements, until the specified number of characters/words (excluding tags!) is exceeded, at which point we append a user-defined tail and discard all other tags.
Update: the latest version of this handy widget is now available as a gem! Check it out at rubygems.org/gems/butter or bundle it with gem install butter.