Blockquotes.js tweak

Jump to menu

26 July 2003

Rendered irrelevant with backend tweak.

I’ve been thinking about quotations and citations lately. Simon Willison’s blockquote citations script is great, and I like using it. The only problem is that the link to the source is given the text ‘source’ , which isn’t particularly helpful.

There was, I seem to recall, some discussion about using the title attribute for this, but the title of a quote is not always going to be the same as the source. Say I’m quoting from The Luzhin Defense: the title will be something like ‘Little Luzhin’s first encounter with chess’ , but the source would be either ‘Vladimir Nabokov’ or ‘The Luzhin Defense’ . So that’s not going to work.

We can embed the source in the blockquote tags, though. The script already does this by manipulating the DOM. I can hear it already: it’s not semantically pure. Perhaps, perhaps not. After all, a citation provides context for a quote, and context is important. Short of wrapping the lot in a container div, this seems to be the best solution.

My version now outputs a citation link if the cite element exists, with that link’s text being the content of a p with a class of ‘cite’ as the blockquote’s last child element; if that doesn’t exist, it’ll be ‘source’ . It’s pretty ugly, but it seems to work. Check it out:

This is a blockquote with a cite attribute and some link text.

— Sean

This is a blockquote with a cite attribute but no link text.

— Source

This is a blockquote without a cite attribute but with what would be link text.

S.

This is a blockquote with neither.