summaryrefslogtreecommitdiff
path: root/lib/coderay/scanners
diff options
context:
space:
mode:
authormurphy <murphy@rubychan.de>2010-05-18 05:45:52 +0000
committermurphy <murphy@rubychan.de>2010-05-18 05:45:52 +0000
commit804dda68dd006b16e0815e19d7dd4bac758ec934 (patch)
treee0c9f969ed85da11afec11d36e7140f7b4e07806 /lib/coderay/scanners
parent3ba349bd7ba1df8e84f7b215e770d7192758666a (diff)
downloadcoderay-804dda68dd006b16e0815e19d7dd4bac758ec934.tar.gz
Improved Python docstring highlighting (closes #190).
Diffstat (limited to 'lib/coderay/scanners')
-rw-r--r--lib/coderay/scanners/python.rb8
1 files changed, 6 insertions, 2 deletions
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