From 0b76ccf2083812ca8b3adfea394bed1f2a8b2271 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 11 Jul 2022 16:52:50 +0100 Subject: [PATCH] Handle bullet points --- content.py | 6 ++++++ tests.py | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/content.py b/content.py index e198ce33f..03d9d9b77 100644 --- a/content.py +++ b/content.py @@ -1481,8 +1481,14 @@ def combine_textarea_lines(text: str) -> str: ctr = 0 paragraphs = text.split('\n\n') for para in paragraphs: + para = para.replace('\n* ', '***BULLET POINT*** ') + para = para.replace('\n * ', '***BULLET POINT*** ') + para = para.replace('\n- ', '***DASH POINT*** ') + para = para.replace('\n - ', '***DASH POINT*** ') para = para.replace('\n', ' ') para = para.replace(' ', ' ') + para = para.replace('***BULLET POINT*** ', '\n* ') + para = para.replace('***DASH POINT*** ', '\n- ') if ctr > 0: result += '

' result += para diff --git a/tests.py b/tests.py index d2f5bf2ef..4bcc5c234 100644 --- a/tests.py +++ b/tests.py @@ -7448,6 +7448,16 @@ def _test_combine_lines(): print('result: ' + result) assert result == expected + text = 'Introduction blurb.\n\n* List item 1\n' + \ + '* List item 2\n* List item 3\n\nFinal blurb.' + expected = 'Introduction blurb.

* List item 1\n' + \ + '* List item 2\n* List item 3

Final blurb.' + result = combine_textarea_lines(text) + if result != expected: + print('expected: ' + expected) + print('result: ' + result) + assert result == expected + def run_all_tests(): base_dir = os.getcwd()