diff --git a/lib/hamlit/parser.rb b/lib/hamlit/parser.rb index 75e7550c..0ba432af 100644 --- a/lib/hamlit/parser.rb +++ b/lib/hamlit/parser.rb @@ -6,6 +6,7 @@ require 'hamlit/concerns/escapable' require 'hamlit/concerns/indentable' require 'hamlit/concerns/line_reader' require 'hamlit/concerns/multiline' +require 'hamlit/parsers/doctype' module Hamlit class Parser < Temple::Parser @@ -14,6 +15,7 @@ module Hamlit include Concerns::Indentable include Concerns::LineReader include Concerns::Multiline + include Parsers::Doctype TAG_ID_CLASS_REGEXP = /[a-zA-Z0-9_-]+/ INTERNAL_STATEMENTS = %w[else elsif when].freeze @@ -91,17 +93,6 @@ module Hamlit end end - def parse_doctype(scanner) - raise SyntaxError unless scanner.scan(/!!!/) - - type = nil - if scanner.scan(/ +/) && scanner.rest? - type = scanner.rest.strip - end - - [:haml, :doctype, options[:format], type] - end - def parse_tag(scanner) tag = DEFAULT_TAG tag = scanner.scan(TAG_REGEXP) if scanner.scan(/%/) diff --git a/lib/hamlit/parsers/doctype.rb b/lib/hamlit/parsers/doctype.rb new file mode 100644 index 00000000..67f5eafb --- /dev/null +++ b/lib/hamlit/parsers/doctype.rb @@ -0,0 +1,16 @@ +module Hamlit + module Parsers + module Doctype + def parse_doctype(scanner) + raise SyntaxError unless scanner.scan(/!!!/) + + type = nil + if scanner.scan(/ +/) && scanner.rest? + type = scanner.rest.strip + end + + [:haml, :doctype, options[:format], type] + end + end + end +end