diff options
author | murphy <murphy@rubychan.de> | 2010-05-18 05:45:52 +0000 |
---|---|---|
committer | murphy <murphy@rubychan.de> | 2010-05-18 05:45:52 +0000 |
commit | 804dda68dd006b16e0815e19d7dd4bac758ec934 (patch) | |
tree | e0c9f969ed85da11afec11d36e7140f7b4e07806 | |
parent | 3ba349bd7ba1df8e84f7b215e770d7192758666a (diff) | |
download | coderay-804dda68dd006b16e0815e19d7dd4bac758ec934.tar.gz |
Improved Python docstring highlighting (closes #190).
-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 |