mirror of https://gitlab.com/bashrc2/epicyon
Adding spaces after full stops
parent
eaf179f704
commit
dbad3f2fbd
2
tests.py
2
tests.py
|
@ -2275,6 +2275,8 @@ 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 = '<p>This string has.</p><p>Two paragraphs.</p>'
|
||||||
|
assert(removeHtml(testStr) == 'This string has. Two paragraphs.')
|
||||||
|
|
||||||
|
|
||||||
def testDangerousCSS():
|
def testDangerousCSS():
|
||||||
|
|
14
utils.py
14
utils.py
|
@ -263,8 +263,18 @@ def removeHtml(content: str) -> str:
|
||||||
removing = False
|
removing = False
|
||||||
elif not removing:
|
elif not removing:
|
||||||
result += ch
|
result += ch
|
||||||
result = result.replace(' ', ' ')
|
|
||||||
result = result.replace('.', '. ')
|
plainText = result.replace(' ', ' ')
|
||||||
|
|
||||||
|
# insert spaces after full stops
|
||||||
|
strLen = len(plainText)
|
||||||
|
result = ''
|
||||||
|
for i in range(strLen):
|
||||||
|
result += plainText[i]
|
||||||
|
if plainText[i] == '.' and i < strLen - 1:
|
||||||
|
if plainText[i + 1] >= 'A' and plainText[i + 1] <= 'Z':
|
||||||
|
result += ' '
|
||||||
|
|
||||||
result = result.replace(' ', ' ').strip()
|
result = result.replace(' ', ' ').strip()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue