mirror of https://gitlab.com/bashrc2/epicyon
Convert html paragraphs
parent
e422d29021
commit
02cbf4a2b9
9
tests.py
9
tests.py
|
@ -2275,8 +2275,15 @@ def testRemoveHtml():
|
||||||
assert(removeHtml(testStr) == testStr)
|
assert(removeHtml(testStr) == testStr)
|
||||||
testStr = 'This string <a href="1234.567">has html</a>.'
|
testStr = 'This string <a href="1234.567">has html</a>.'
|
||||||
assert(removeHtml(testStr) == 'This string has html.')
|
assert(removeHtml(testStr) == 'This string has html.')
|
||||||
|
testStr = '<label>This string has.</label><label>Two labels.</label>'
|
||||||
|
assert(removeHtml(testStr) == 'This string has. Two labels.')
|
||||||
testStr = '<p>This string has.</p><p>Two paragraphs.</p>'
|
testStr = '<p>This string has.</p><p>Two paragraphs.</p>'
|
||||||
assert(removeHtml(testStr) == 'This string has. Two paragraphs.')
|
assert(removeHtml(testStr) == 'This string has.\n\nTwo paragraphs.')
|
||||||
|
testStr = 'This string has.<br>A new line.'
|
||||||
|
assert(removeHtml(testStr) == 'This string has.\nA new line.')
|
||||||
|
testStr = '<p>This string contains a url http://somesite.or.other</p>'
|
||||||
|
assert(removeHtml(testStr) == \
|
||||||
|
'This string contains a url http://somesite.or.other')
|
||||||
|
|
||||||
|
|
||||||
def testDangerousCSS():
|
def testDangerousCSS():
|
||||||
|
|
1
utils.py
1
utils.py
|
@ -255,6 +255,7 @@ def removeHtml(content: str) -> str:
|
||||||
removing = False
|
removing = False
|
||||||
content = content.replace('<a href', ' <a href')
|
content = content.replace('<a href', ' <a href')
|
||||||
content = content.replace('<q>', '"').replace('</q>', '"')
|
content = content.replace('<q>', '"').replace('</q>', '"')
|
||||||
|
content = content.replace('</p>', '\n\n').replace('<br>', '\n')
|
||||||
result = ''
|
result = ''
|
||||||
for ch in content:
|
for ch in content:
|
||||||
if ch == '<':
|
if ch == '<':
|
||||||
|
|
Loading…
Reference in New Issue