'Checks that strings with HTML are not concatenated
Arguments:
file_contents: The contents of the JavaScript file.
rule: The rule that was violated if this fails.
results: A file results objects to which violations will be added.'

def _check_concat_with_html(self, file_contents, rule, results):

    lines = StringLines(file_contents)
    last_expression = None
    regex_string_with_html = "\n                                                {quote}                                                                                                                    #    Opening    quote.\n                                                                (\n                                                                            \\s*<                                                                                                    #    Starts    with    '<'    (ignoring    spaces)\n                                                                            ([^{quote}]|[\\\\]{quote})*                #    followed    by    anything    but    a    closing    quote.\n                                                                |                                                                                                                            #    Or,\n                                                                            ([^{quote}]|[\\\\]{quote})*                #    Anything    but    a    closing    quote\n                                                                            >\\s*                                                                                                    #    ending    with    '>'    (ignoring    spaces)\n                                                                )\n                                                {quote}                                                                                                                    #    Closing    quote.\n                                "
    regex_string_with_html = '({}|{})'.format(regex_string_with_html.format(quote="'"), regex_string_with_html.format(quote='"'))
    regex_concat_with_html = re.compile('(\\+\\s*{string_with_html}|{string_with_html}\\s*\\+)'.format(string_with_html=regex_string_with_html), re.VERBOSE)
    for match in regex_concat_with_html.finditer(file_contents):
        found_new_violation = False
        if (last_expression is not None):
            last_line = lines.index_to_line_number(last_expression.start_index)
            if (last_line == lines.index_to_line_number(match.start())):
                last_expression = Expression(last_expression.start_index, match.end(), template=file_contents)
            else:
                results.violations.append(ExpressionRuleViolation(rule, last_expression))
                found_new_violation = True
        else:
            found_new_violation = True
        if found_new_violation:
            last_expression = Expression(match.start(), match.end(), template=file_contents)
    if (last_expression is not None):
        results.violations.append(ExpressionRuleViolation(rule, last_expression))
