Handle bullet points

main
Bob Mottram 2022-07-11 16:52:50 +01:00
parent ab62dcfe73
commit 0b76ccf208
2 changed files with 16 additions and 0 deletions

View File

@ -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 += '</p><p>'
result += para

View File

@ -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.</p><p>* List item 1\n' + \
'* List item 2\n* List item 3</p><p>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()