diff --git a/lib/rouge/guessers/disambiguation.rb b/lib/rouge/guessers/disambiguation.rb index f78654fb34..0bf14bb234 100644 --- a/lib/rouge/guessers/disambiguation.rb +++ b/lib/rouge/guessers/disambiguation.rb @@ -101,6 +101,12 @@ def match?(filename) Cpp end + + disambiguate '*.plist' do + next XML if matches?(/\A<\?xml\b/) + + Plist + end end end end diff --git a/lib/rouge/lexers/xml.rb b/lib/rouge/lexers/xml.rb index 0b95b3709c..23d92e9b4f 100644 --- a/lib/rouge/lexers/xml.rb +++ b/lib/rouge/lexers/xml.rb @@ -7,7 +7,7 @@ class XML < RegexLexer title "XML" desc %q(XML) tag 'xml' - filenames *%w(*.xml *.xsl *.rss *.xslt *.xsd *.wsdl *.svg) + filenames *%w(*.xml *.xsl *.rss *.xslt *.xsd *.wsdl *.svg *.plist) mimetypes *%w( text/xml application/xml diff --git a/spec/lexers/plist_spec.rb b/spec/lexers/plist_spec.rb index fb19151b86..3e2045f11a 100644 --- a/spec/lexers/plist_spec.rb +++ b/spec/lexers/plist_spec.rb @@ -8,11 +8,17 @@ it 'guesses by filename' do assert_guess :filename => 'foo.pbxproj' + assert_guess :filename => 'foo.plist', :source => 'foo' end it 'guesses by mimetype' do assert_guess :mimetype => 'text/x-plist' assert_guess :mimetype => 'application/x-plist' end + + it 'does not guess XML-encoded plists' do + deny_guess :filename => 'foo.plist', :mimetype => 'application/xml' + deny_guess :filename => 'foo.plist', :source => '' + end end end diff --git a/spec/lexers/xml_spec.rb b/spec/lexers/xml_spec.rb index bf8e55429d..b1b5a2cf24 100644 --- a/spec/lexers/xml_spec.rb +++ b/spec/lexers/xml_spec.rb @@ -16,6 +16,8 @@ assert_guess :filename => 'foo.xsd' assert_guess :filename => 'foo.wsdl' assert_guess :filename => 'foo.svg' + assert_guess :filename => 'foo.plist', :source => '' + deny_guess :filename => 'foo.plist', :source => 'foo' end it 'guesses by mimetype' do