protected function unmarkedText($text)
    {
        $newText = "";

        if ($this->breaksEnabled)
        {
            $parts = mb_split('[ ]*\n', $text);
        }
        else
        {
            $parts = mb_split('(?:[ ][ ]+|[ ]*\\\\)\n', $text);
        }

        foreach ($parts as $index => &$part)
        {
            if ($index > 0)
            {
                $newText .= "<br />\n";
            }

            // Remove trailing spaces.
            $part = mb_ereg_replace('/[ ]*\n/', "\n", $part);

            // Determine directon
            $ltr = $this->getLtrStrLen($part);
            $rtl = $this->getRtlStrLen($part);
            $dir = null;

            if ($this->isLtr() && $rtl > 0 && $rtl > $ltr)
            {
                $dir = "rtl";
            }
            else if ($this->isRtl() && $ltr > 0 && $ltr > $rtl)
            {
                $dir = "ltr";
            }

            if (!is_null($dir))
            {
                $newText .= "<div dir=\"{$dir}\">{$part}</div>";
            }
            else
            {
                $newText .= $part;
            }
        }

        return $newText;
    }