Recently I’ve been learning DOM scripting with the help of an excellent book called… well… DOM Scripting. (Creative, these computer types, eh wot?) As I went through the book, I had what I thought was a great idea for a script to auto-create pull-quotes.
Well darn it all if some guy named Roger Johansson didn’t go and save me the trouble by beating me to the punch. I actually laughed when I saw his post, because he uses precisely the methodology I was planning, and he pulls it off well — though, even more coincidentally, his first iteration had a limitation that mine would have had, and for the same reason! (I should note here that I’m not trying to take anything away from Roger — obviously I think it was a good idea, and he did clearly beat me to it.)
Almost immediately, a reader of his blog (going by the nom de web “Viper007Bond”) took the script and very neatly turned it into a plugin for WordPress. Better and better. It wouldn’t have been too terribly hard to incorporate it into a blog, but now it’s a total no-brainer.
Since I had been thinking directly along the same lines before seeing the script, I of course immediately had ideas of what might be done differently. I have a number of concepts that I will work on soon, but one of them is already done. I added code to Roger’s that excludes <a> tags from within “pullquote” <span>s — Not the content of the links, just the link itself. It occurred to me that having a link inside pullquote would not look so good, and in some cases could actually damage navigation within a page (in the cases of “name” links or navigational links pointing to “name” links). You can see it in action in this post from my other blog.
The modified script can be downloaded right here. This can easily be used with the WordPress plugin — just replace the “jspullquotes.js” file in the plugin folder with the modified copy. (Actually, this is an excellent quality of the way Viper007Bond made the plugin, as it is so easily updated when improvements are made to the original script!)
Some of the ideas I have for down the road include:
- If a quote span doesn’t start with a capital letter, [C]apitalize it within brackets, as would be proper grammar for a quote
- Allowing pullquotes that actually differ from the text in the span, such as excluding clauses within a long sentence. I actually think this will be easier than it sounds.
- Make successive pullquotes in a single post alternate sides
- Figure out how to make a preference screen within WordPress so that these various improvements1 can be easily turned on or off by the blog owner
That’s all I’ve got for now. Those links again are:
- Roger Johansson’s script
- Viper007Bond’s WordPress Plugin
- My “No Links” modified script
- Update: My full-feature WordPress Plugin
That’s it for now. See you next time!