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

+17
View File
@@ -40,6 +40,14 @@ module Oga
class Lexer
attr_reader :html
##
# Element name used to determine if a tag being processed is a Javascript
# tag.
#
# @return [String]
#
SCRIPT_TAG = 'script'.freeze
##
# @param [String|IO] data The data to lex. This can either be a String or
# an IO instance.
@@ -181,6 +189,15 @@ module Oga
return @elements.last
end
##
# Returns true if the current element is the HTML `<script>` element.
#
# @return [TrueClass|FalseClass]
#
def inside_html_script?
return html? && current_element == SCRIPT_TAG
end
##
# Called when processing a single quote.
#