formatting errors with multiple lexers

Issue #242 resolved
Former user created an issue

I've found that pygments doesn't do multiple lexers that well if the child lexer can embed the end tag in the string. For instance, this block of html+javascript doesn't format correctly:

{{{
<html>
<script type="type/javascript">
val a = "b c d d ";
val x = "hello hi how are you </script> x y z </foo>!";
val y = 1 + 2;
</script>
</html>
}}}

I would imagine the proper way to do this would be to make a HtmlJavascriptLexer that HtmlLexer uses, which does a pop if it finds a </script> in the top level, but I'm not sure the best way to do this.

Reported by guest

Comments (8)

  1. thatch

    This is a bug but I've seen browsers mess up in the same way (which results in the workaround `'</scr' + 'ipt>'` in this case.

  2. Armin Ronacher

    That's not valid HTML and without cdata no valid XML either. In HTML inside a CDATA section no "</" followed by a tag name token is allowed. You have to write "<
    /script"> inside your javascript code.

  3. Log in to comment