Merge pull request #650 from michael-lazar/submissions_stripping_newlines

Prevent stripping newlines in the middle of markdown submissions
This commit is contained in:
Michael Lazar
2019-02-13 10:34:03 -05:00
committed by GitHub
2 changed files with 5 additions and 1 deletions

View File

@@ -912,7 +912,7 @@ class Terminal(object):
flags = re.MULTILINE | re.DOTALL flags = re.MULTILINE | re.DOTALL
pattern = '<!--{token}(.*?){token}-->'.format(token=TOKEN) pattern = '<!--{token}(.*?){token}-->'.format(token=TOKEN)
text = re.sub(pattern, '', text, flags=flags) text = re.sub(pattern, '', text, flags=flags)
return re.sub( '^[\s\n]*\n', '', text, flags=flags).rstrip() return re.sub('\A[\s\n]*\n', '', text, flags=flags).rstrip()
def clear_screen(self): def clear_screen(self):
""" """

View File

@@ -709,6 +709,10 @@ def test_terminal_strip_instructions(terminal):
text = '\n \n code\n block\n' text = '\n \n code\n block\n'
assert terminal.strip_instructions(text) == ' code\n block' assert terminal.strip_instructions(text) == ' code\n block'
# However, blank lines in the middle of comment should not be stripped
text = 'paragraph 1\n\nparagraph 2\n'
assert terminal.strip_instructions(text) == 'paragraph 1\n\nparagraph 2'
def test_terminal_get_link_pages(terminal): def test_terminal_get_link_pages(terminal):