How to modify the comment body while in comment.tpl.php At a Drupal 7 website dedicated to a card game I'm trying to color the special characters for hearts and diamonds in all plain_text comments red.

Since I haven't found the way to modify the text filter yet, I'm trying to "hack" the file themes/bartik/templates/comment.tpl.php as workaround by inserting the 5 lines below:

&lt;div class="content"&lt;?php print $content_attributes; ?&gt;&gt;
  &lt;?php
    // We hide the comments and links now so that we can render them later.
    hide($content['links']);

    $body = $comment-&gt;comment_body[LANGUAGE_NONE][0]['value'];
    $body =  str_replace('♦', '&lt;font color="red"&gt;♦&lt;/font&gt;', $body);
    $body =  str_replace('♥', '&lt;font color="red"&gt;♥&lt;/font&gt;', $body);
    print "\n&lt;!--\n" . $body . "\n--&gt;\n";
    $comment-&gt;comment_body[LANGUAGE_NONE][0]['value'] = $body;

    print render($content);
  ?&gt;


In the HTML comment between &lt;!-- and --&gt; above I can see that the string substitution has worked okay.

But the comment itself isn't modified.

I've tried modifying both $comment-&gt;comment_body[LANGUAGE_NONE][0]['value'] and $comment-&gt;comment_body[LANGUAGE_NONE][0]['safe_value'] but the comment is still unchanged.

I've studied the output of print_r($content) and var_dump($content) but still can't figure out how to modify the comment body.
If you insist, you can always go like that:

 print str_replace(
   array('♦','♥'),
   array('&lt;font color="red"&gt;♦&lt;/font&gt;', '&lt;font color="red"&gt;♥&lt;/font&gt;'),
   render($content)
 );


But instead of deprecated &lt;font&gt;, use &lt;span class=""&gt; and CSS. Consider classes for all 4 colours, for black and red, and for card marks altogether, for future styling ease.