diff options
-rw-r--r-- | Changes.textile | 10 | ||||
-rw-r--r-- | lib/coderay/scanners/python.rb | 8 |
2 files changed, 11 insertions, 7 deletions
diff --git a/Changes.textile b/Changes.textile index 90a7cda..8b84cc2 100644 --- a/Changes.textile +++ b/Changes.textile @@ -131,15 +131,15 @@ h3. @Scanners::Java@ h3. @Scanners::Plaintext@ -* *CHANGED*: Docstrings are highlighted as @:comment@. - See "#190":http://redmine.rubychan.de/issues/190. - -h3. @Scanners::Python@ - * *IMPROVED*: Just returns the string without scanning (faster). This is much faster than scanning until @/\z/@ in Ruby 1.8. +h3. @Scanners::Python@ + +* *CHANGED*: Docstrings are highlighted as @:comment@. + See "#190":http://redmine.rubychan.de/issues/190. + h3. @Scanners::Ruby@ * *ADDED* more predefined keywords (see http://murfy.de/ruby-constants). diff --git a/lib/coderay/scanners/python.rb b/lib/coderay/scanners/python.rb index b01248a..56b9ae6 100644 --- a/lib/coderay/scanners/python.rb +++ b/lib/coderay/scanners/python.rb @@ -94,6 +94,10 @@ module Scanners | \* /x # :nodoc: + DOCSTRING_COMING = / + [ \t]* u?r? ("""|''') + /x # :nodoc: + protected def scan_tokens encoder, options @@ -102,7 +106,7 @@ module Scanners string_delimiter = nil string_raw = false string_type = nil - docstring_coming = false + docstring_coming = match?(/#{DOCSTRING_COMING}/o) import_clause = class_name_follows = last_token_dot = false unicode = string.respond_to?(:encoding) && string.encoding.name == 'UTF-8' from_import_state = [] @@ -139,7 +143,7 @@ module Scanners encoder.text_token match, :space if match == "\n" state = :initial if state == :include_expected - docstring_coming = true if match?(/[ \t]*u?r?"""/) + docstring_coming = true if match?(/#{DOCSTRING_COMING}/o) end next |