Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ The most up-to-date lexer and highlighter for [_Mathematica_](http://wolfram.com
source code using the [pygments](http://pygments.org) engine.

![](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)
![](https://img.shields.io/badge/version-0.4.0-yellow.svg?style=flat-square)
![](https://img.shields.io/travis/rsmenon/pygments-mathematica/master.svg?style=flat-square)
![](https://img.shields.io/badge/version-0.4.1-yellow.svg?style=flat-square)
![](https://img.shields.io/badge/python-3.9%2B-lightgrey.svg?style=flat-square)
![](https://img.shields.io/pypi/v/pygments-mathematica.svg?style=flat-square)
## Features
Expand Down
6 changes: 1 addition & 5 deletions mathematica/lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ class MathematicaLexer(RegexLexer):
(Regex.INTEGER, MToken.NUMBER),
],
'strings': [
(r'[^"\\]+', MToken.STRING),
(r'^[\\"]', MToken.STRING),
(r'(\\n|\\r)', MToken.STRING),
(r'\\"', MToken.STRING),
(r'\\', MToken.STRING),
(r'([^"\\]|\\.)+', MToken.STRING),
(r'"', MToken.STRING, '#pop'),
],
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

setup(
name='pygments-mathematica',
version='0.4.0',
version='0.4.1',
description='Mathematica/Wolfram Language Lexer for Pygments',
long_description=__doc__,
author='rsmenon',
Expand Down
21 changes: 13 additions & 8 deletions tests/test_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,17 @@ def test_strings(self):
],
[
(MToken.STRING, '"'),
(MToken.STRING, 'a string '),
(MToken.STRING, '\\"'),
(MToken.STRING, ' with a quote'),
(MToken.STRING, 'a string \\" with a quote'),
(MToken.STRING, '"'),
],
[
(MToken.STRING, '"'),
(MToken.STRING, 'a string with a newline'),
(MToken.STRING, '\\n'),
(MToken.STRING, 'a string with a newline\\n'),
(MToken.STRING, '"'),
],
[
(MToken.STRING, '"'),
(MToken.STRING, 'a string with '),
(MToken.STRING, '\\'),
(MToken.STRING, ' two backslashes'),
(MToken.STRING, 'a string with \\ two backslashes'),
(MToken.STRING, '"'),
]
]
Expand Down Expand Up @@ -393,3 +388,13 @@ def test_lexical_scope_nasty(self):
(MToken.GROUP, ']'),
]
self.verify(code, expected)

def test_string_closing_quote_on_newline(self):
code = '"test string\n"abc'
expected = [
(MToken.STRING, '"'),
(MToken.STRING, 'test string\n'),
(MToken.STRING, '"'),
(MToken.SYMBOL, 'abc'),
]
self.verify(code, expected)