Drupal strips all HTML from node titles when they're displayed to prevent XSS exploits. However, there are some cases where inline HTML elements are needed, such as when titles contain scientific names.
To work around this, we will use pseudotags like [i] and [/i] which Drupal will safely translate into real HTML tags when the page is displayed.
We need two new functions (please note that Drupal best practices are to include functions in template.php or a custom module; logic should not be placed in *.tpl.php).
function bb2html($text) {
$bbcode = array(
"[strong]", "[/strong]",
"[b]", "[/b]",
"[u]", "[/u]",
"[i]", "[/i]",
"[em]", "[/em]"
);
$htmlcode = array(
"<strong>", "</strong>",
"<strong>", "</strong>",
"<u>", "</u>",
"<em>", "</em>",
"<em>", "</em>"
);
return str_replace($bbcode, $htmlcode, $text);
}
function bb_strip($text) {
$bbcode = array(
"[strong]", "[/strong]",
"[b]", "[/b]",
"[u]", "[/u]",
"[i]", "[/i]",
"[em]", "[/em]"
);
return str_replace($bbcode, '', $text);
}