diff options
author | gbrandl <devnull@localhost> | 2008-09-19 18:34:45 +0000 |
---|---|---|
committer | gbrandl <devnull@localhost> | 2008-09-19 18:34:45 +0000 |
commit | f217fdc4eefa21b66a8767bc74e7d89edc67f927 (patch) | |
tree | a159d181cc4159db35b3a64997e9e8d03b01acf1 | |
parent | e6600347dac8dddc630cac6e55c08dea84b20f00 (diff) | |
download | pygments-f217fdc4eefa21b66a8767bc74e7d89edc67f927.tar.gz |
Fix newline problem.
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | pygments/lexer.py | 7 |
2 files changed, 7 insertions, 4 deletions
@@ -5,6 +5,10 @@ Version 0.12 ------------ (codename not selected, release XXX XX, 2008) +- Don't use join(splitlines()) when converting newlines to ``\n``, + because that doesn't keep all newlines at the end when the + ``stripnl`` lexer option is False. + - Add Tango style, written by Andre Roberge for the Crunchy project. - Add Python3TracebackLexer and ``python3`` option to diff --git a/pygments/lexer.py b/pygments/lexer.py index 5c41d4a2..cba93e4f 100644 --- a/pygments/lexer.py +++ b/pygments/lexer.py @@ -127,10 +127,9 @@ class Lexer(object): Also preprocess the text, i.e. expand tabs and strip it if wanted and applies registered filters. """ - if isinstance(text, unicode): - text = u'\n'.join(text.splitlines()) - else: - text = '\n'.join(text.splitlines()) + text = text.replace('\r\n', '\n') + text = text.replace('\r', '\n') + if not isinstance(text, unicode): if self.encoding == 'guess': try: text = text.decode('utf-8') |