private function highlight($str, $start, $length) {
        $parts = array(
            substr($str, 0, $start),
            substr($str, $start, $length),
            substr($str, $start + $length)
        );

        $parts = array_map('htmlentities', $parts);

        $highlighted  = $parts[0] . '<span class="' . $this->highlightClassName . '">';
        $highlighted .= $parts[1] . '</span>' . $parts[2];

        return $highlighted;
    }