Extra blockquote check

main
Bob Mottram 2020-09-14 11:25:12 +01:00
parent f658cbeb30
commit 488ef5b34d
2 changed files with 17 additions and 1 deletions

View File

@ -26,9 +26,15 @@ def htmlReplaceEmailQuote(content: str) -> str:
if not lineStr:
continue
if '>> ' not in lineStr:
newContent += '<p>' + lineStr + '</p>'
if lineStr.startswith('&gt; '):
lineStr = lineStr.replace('&gt; ', '<blockquote>')
lineStr = lineStr.replace('&gt;', '<br>')
newContent += '<p>' + lineStr + '</blockquote></p>'
else:
newContent += '<p>' + lineStr + '</p>'
else:
lineStr = lineStr.replace('>&gt; ', '><blockquote>')
lineStr = lineStr.replace('&gt;', '<br>')
newContent += '<p>' + lineStr + '</blockquote></p>'
return newContent

View File

@ -2149,6 +2149,16 @@ def testReplaceEmailQuote():
print('Expect: ' + expectedStr)
assert resultStr == expectedStr
testStr = "<p>Some text:</p><p>&gt; first line-&gt;second line</p>" + \
"<p>Some question?</p>"
expectedStr = "<p>Some text:</p><p><blockquote>first line-<br>" + \
"second line</blockquote></p><p>Some question?</p>"
resultStr = htmlReplaceEmailQuote(testStr)
if resultStr != expectedStr:
print('Result: ' + resultStr)
print('Expect: ' + expectedStr)
assert resultStr == expectedStr
def runAllTests():
print('Running tests...')