mirror of https://gitlab.com/bashrc2/epicyon
Handle bullet points
parent
ab62dcfe73
commit
0b76ccf208
|
@ -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
|
||||
|
|
10
tests.py
10
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.</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()
|
||||
|
|
Loading…
Reference in New Issue