Lex contents of <script> tags as plain text.

When lexing input in HTML mode the lexer has to treat _all_ content of a
<script> tag as plain text. This ensures that the lexer can process input such
as "x <y" and "// <foo>" correctly.

Fixes #70.
This commit is contained in:
Yorick Peterse committed 2015-03-02 16:22:09 +01:00
1 parent 351b5ac004
commit ba2177e2cf
4 files changed
+73 -2

No files matched your search

+35 -1
View File
@@ -327,7 +327,17 @@
# We're done with the open tag of the element.
'>' => {
callback_simple(id_on_element_open_end);
fnext main;
if ( inside_html_script_p() )
{
mark = ts + 1;
fnext script_text;
}
else
{
fnext main;
}
};
# Self closing tags.
@@ -391,6 +401,30 @@
};
*|;
# <script> tags in HTML can contain basically anything except for the
# literal "</script>". As a result of this we can't use the regular text
# machine.
script_text := |*
'</script>' => {
callback(id_on_text, data, encoding, mark, ts);
mark = 0;
if ( lines > 0 )
{
advance_line(lines);
lines = 0;
}
callback_simple(id_on_element_end);
fnext main;
};
any $count_newlines;
*|;
# The main machine aka the entry point of Ragel.
main := |*
doctype_start => start_doctype;