ContentFor = function (line, regexp) {
    if (!line.Match) {
        return EscapeHtml(line.Content);
    }
    var content = line.Content,
        buffer = [];

    while (true) {
        regexp.lastIndex = 0;
        var m = regexp.exec(content);
        if (!m) {
            buffer.push(EscapeHtml(content));
            break;
        }

        buffer.push(
            EscapeHtml(content.substring(0, regexp.lastIndex - m[0].length))
        );
        buffer.push("<em>" + EscapeHtml(m[0]) + "</em>");
        content = content.substring(regexp.lastIndex);
    }
    return buffer.join("");
}
Produce html for a line using the regexp to highlight matches.