Permalink
Browse files

Make docstring regex non-greedy. Fixes #89

  • Loading branch information...
1 parent 355ffce commit e0b555dae5093c574b4583a614796dfd93495c08 @ccampbell committed Nov 27, 2012
Showing with 23 additions and 3 deletions.
  1. +2 −2 js/language/python.js
  2. +20 −0 tests/language/python-test.js
  3. +1 −1 util/builder.py
@@ -2,7 +2,7 @@
* Python patterns
*
* @author Craig Campbell
- * @version 1.0.6
+ * @version 1.0.7
*/
Rainbow.extend('python', [
/**
@@ -79,6 +79,6 @@ Rainbow.extend('python', [
},
{
'name': 'comment.docstring',
- 'pattern': /('{3}|"{3})[\s\S]*\1/gm
+ 'pattern': /('{3}|"{3})[\s\S]*?\1/gm
}
]);
@@ -151,4 +151,24 @@ RainbowTester.run(
'yes"""</span>'
);
+RainbowTester.run(
+ 'multiple docstrings',
+
+ '"""\n' +
+ 'x\n' +
+ '"""\n' +
+ '2 + 2\n' +
+ '"""\n' +
+ 'y\n' +
+ '"""',
+
+ '<span class="comment docstring">"""\n' +
+ 'x\n' +
+ '"""</span>\n' +
+ '<span class="constant numeric">2</span> <span class="keyword operator">+</span> <span class="constant numeric">2</span>\n' +
+ '<span class="comment docstring">"""\n' +
+ 'y\n' +
+ '"""</span>'
+);
+
RainbowTester.endTest('python');
View
@@ -24,7 +24,7 @@ def __init__(self, js_path, closure_path, theme_path=None):
'javascript': '1.0.7',
'lua': '1.0',
'php': '1.0.6',
- 'python': '1.0.6',
+ 'python': '1.0.7',
'r': '1.0',
'ruby': '1.0.5',
'scheme': '1.0',

0 comments on commit e0b555d

Please sign in to comment.