Adding spaces after full stops

merge-requests/30/head
Bob Mottram 2021-03-23 10:38:03 +00:00
parent eaf179f704
commit dbad3f2fbd
2 changed files with 14 additions and 2 deletions

View File

@ -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():

View File

@ -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