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:
1 parent
351b5ac004
commit
ba2177e2cf
4 files changed
+73
-2
No files matched your search
@@ -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.
|
||||
#
|
||||
|
||||
Reference in new issue
Block a user