private function formatString($s)
    {
        static $last_tag = null;

        if ($this->m_stack->count() > 0
            && $this->m_stack->top()->isOfType(self::TAG_PRE)
        ) {
            // Do not format text inside of TAG_PRE tags

            return $s;
        }

        /*
         * TODO Replace double-quotes alternately with nice left and right
         * quotes
         */

        if ($last_tag !== null) {
            #echo $last_tag->getName();
        }

        #echo '|' . $s . '|';

        // opening quote
        if ($last_tag !== null && $last_tag->isOfType(self::TAG_INLINE)) {
            $s = preg_replace('/([\s])&quot;/', '\1&raquo;', $s);

            #echo 'without';
        } else {
            $s = preg_replace('/([\s]|^)&quot;/', '\1&raquo;', $s);
        }

        // [X][X] will always be rendered as [S][S], not as [S][E]
        $s = preg_replace('/(&raquo;)&quot;/', '\1&raquo;', $s);

        #echo '<br />';

        // everything else is closing quote
        $s = str_replace('&quot;', '&laquo;', $s);

        $s = str_replace('--', '&ndash;', $s);

        if ($this->m_stack->count() > 0) {
            $last_tag = $this->m_stack->top();
        } else {
            $last_tag = null;
        }

        $e = function ($s) { return htmlspecialchars($s, ENT_QUOTES, 'UTF-8'); };

        return $e($s);
    }