From ba2177e2cfda958ea12c5b04dbf60907aaa8816d Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 2 Mar 2015 16:20:54 +0100 Subject: [PATCH] Lex contents of ". As a result of this we can't use the regular text + # machine. + script_text := |* + '' => { + 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; diff --git a/lib/oga/xml/lexer.rb b/lib/oga/xml/lexer.rb index fa1757c..14f0784 100644 --- a/lib/oga/xml/lexer.rb +++ b/lib/oga/xml/lexer.rb @@ -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 `