diff options
author | Waylan Limberg <waylan@gmail.com> | 2013-02-14 11:46:30 -0500 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2013-02-14 11:46:30 -0500 |
commit | fdfc84405ba690705ff343d46ab658bfc50a8836 (patch) | |
tree | e148284f3afbd85bfe5970bc7cbb15df1b4f3492 /markdown/preprocessors.py | |
parent | 5c5612a404f920e08aacfb50fcf4eca08a994d17 (diff) | |
download | markdown-fdfc84405ba690705ff343d46ab658bfc50a8836.tar.gz markdown-fdfc84405ba690705ff343d46ab658bfc50a8836.tar.bz2 markdown-fdfc84405ba690705ff343d46ab658bfc50a8836.zip |
Preserve all blank lines in code blocks.
Fixes #183. Finally got this working properly. The key was
using a regex substitution with non-overlapping matches that
removed all whitespace from the begining of *all* blank lines
when normalizing whitespace.
Once I got that, I could simplfy the EmptyBlockProcessor
and easily output one or two blank lines appropriately.
A blank block gets two new lines (`'\n\n'`), while a
block which starts with a newline gets one.
Diffstat (limited to 'markdown/preprocessors.py')
-rw-r--r-- | markdown/preprocessors.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index 3751264..6238303 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -50,7 +50,7 @@ class NormalizeWhitespace(Preprocessor): source = source.replace(util.STX, "").replace(util.ETX, "") source = source.replace("\r\n", "\n").replace("\r", "\n") + "\n\n" source = source.expandtabs(self.markdown.tab_length) - source = re.sub(r'\n +\n', '\n\n', source) + source = re.sub(r'(?<=\n) +\n', '\n', source) return source.split('\n') |