Skip to content

Commit

Permalink
Ensure XML lexer handles unknown DOCTYPEs (#1348)
Browse files Browse the repository at this point in the history
The Mason lexer mistakenly handles unknown DOCTYPEs. This commit ensures
that the XML lexer handles unknown DOCTYPEs and adds a test to prevent
future regressions.
  • Loading branch information
johnfairh authored and pyrmont committed Oct 13, 2019
1 parent b357204 commit abbf5fa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
5 changes: 0 additions & 5 deletions lib/rouge/lexers/mason.rb
Expand Up @@ -15,11 +15,6 @@ def initialize(*)
@perl = Perl.new
end

def self.detect?(text)
return false if text.doctype?(/((?:ht|x)ml)/)
return true if text.doctype?
end

# Note: If you add a tag in the lines below, you also need to modify "disambiguate '*.m'" in file disambiguation.rb
TEXT_BLOCKS = %w(text doc)
PERL_BLOCKS = %w(args flags attr init once shared perl cleanup filter)
Expand Down
1 change: 1 addition & 0 deletions spec/lexers/xml_spec.rb
Expand Up @@ -34,6 +34,7 @@
assert_guess :source => '<?xml version="1.0" ?><html destdir="${reportfolderPath}" encoding="utf-8" />'
assert_guess :source => '<!DOCTYPE xml>'
deny_guess :source => '<!DOCTYPE html>'
assert_guess :source => '<!DOCTYPE unknown>'
end
end
end

0 comments on commit abbf5fa

Please sign in to comment.