1
0
Fork 0
mirror of https://github.com/haml/haml.git synced 2022-11-09 12:33:31 -05:00

Carve out parse_doctype into Parsers::Doctype

This commit is contained in:
Takashi Kokubun 2015-03-29 12:34:46 +09:00
parent d3984964f3
commit 51d5cb5829
2 changed files with 18 additions and 11 deletions

View file

@ -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(/%/)

View file

@ -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