Skip to content

Commit

Permalink
Make docstring regex non-greedy. Fixes #89
Browse files Browse the repository at this point in the history
  • Loading branch information
ccampbell committed Nov 27, 2012
1 parent 355ffce commit e0b555d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions js/language/python.js
Expand Up @@ -2,7 +2,7 @@
* Python patterns * Python patterns
* *
* @author Craig Campbell * @author Craig Campbell
* @version 1.0.6 * @version 1.0.7
*/ */
Rainbow.extend('python', [ Rainbow.extend('python', [
/** /**
Expand Down Expand Up @@ -79,6 +79,6 @@ Rainbow.extend('python', [
}, },
{ {
'name': 'comment.docstring', 'name': 'comment.docstring',
'pattern': /('{3}|"{3})[\s\S]*\1/gm 'pattern': /('{3}|"{3})[\s\S]*?\1/gm
} }
]); ]);
20 changes: 20 additions & 0 deletions tests/language/python-test.js
Expand Up @@ -151,4 +151,24 @@ RainbowTester.run(
'yes"""</span>' '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'); RainbowTester.endTest('python');
2 changes: 1 addition & 1 deletion util/builder.py
Expand Up @@ -24,7 +24,7 @@ def __init__(self, js_path, closure_path, theme_path=None):
'javascript': '1.0.7', 'javascript': '1.0.7',
'lua': '1.0', 'lua': '1.0',
'php': '1.0.6', 'php': '1.0.6',
'python': '1.0.6', 'python': '1.0.7',
'r': '1.0', 'r': '1.0',
'ruby': '1.0.5', 'ruby': '1.0.5',
'scheme': '1.0', 'scheme': '1.0',
Expand Down

0 comments on commit e0b555d

Please sign in to comment.