After reading Mark Pilgrim's article about the Q tag, I decided, "me too!" Except that it doesn't display correctly in Internet Explorer, I wrote a filter, first for WordPress, and now for Drupal, which takes <q>text</q> or <q cite="[url]">text</q> with just <span class="q">text</span>. In my articles, I still use the Q tag, in the hopes of one day running a script to make a ranked list of the URLs I've quoted over the years. Note that the escaping below is correct, and necessary for the description to appear correctly in administer » modules.
You'll need to save the module as quotable.info
and quotable.module
. It adds a filter called "Quotable" which you will have to enable for your input formats under Administer → Site configuration → Input formats.
quotable.info
name = Quotable
description = "Replaces the q element with curly quotes and a stylable wrapper"
core = 6.x
quotable.module
<?php
/**
* Implementation of hook_filter().
*/
function quotable_filter($op, $delta = 0, $format = -1, $text = '') {
switch ($op) {
case 'list':
return array(0 => t('Quotable filter'));
case 'description':
return t('Replaces the <q cite="[url]"> element with a <span class="q"> wrapper');
case 'process':
$replace = preg_replace("/<q[^>]*>(([^<]|<[^\/]|<\/[^q])*)<\/q>/", "<span class=\"q\">“\$1”</span>", $text);
return $replace;
default:
return $text;
}
}
/**
* Implementation of hook_filter_tips().
*/
function quotable_filter_tips($delta, $format, $long = FALSE) {
return t('Replaces the <q cite="[url]"> element with a <span class="q"> wrapper');
}