From 463192242f37123d84a5682ea0ce87ecd801aba4 Mon Sep 17 00:00:00 2001
From: Bob Mottram ' + lineStr + ' ' + lineStr + '' not in content:
+ return content
+ if '
' not in content:
+ return content
+ ctr = 1
+ found = True
+ while found:
+ prefix = content.split('', ctr)[0] + '
')[0]
+ if ''
+ quotedStr = content.split('
')[1]
+ quotedStr = quotedStr.split('', ctr)[1]
+ if '
' not in quotedStr:
+ found = False
+ else:
+ endStr = quotedStr.split('' not in endStr:
+ found = False
+ if '
' in quotedStr:
+ quotedStr = quotedStr.replace('
', '')
+ content = prefix + quotedStr + '
' + endStr
+ ctr += 1
+ return content
+
def htmlReplaceEmailQuote(content: str) -> str:
"""Replaces an email style quote "> Some quote" with html blockquote
@@ -44,9 +69,12 @@ def htmlReplaceEmailQuote(content: str) -> str:
newContent += '')
- lineStr = lineStr.replace('>', '
')
+ if lineStr.startswith('>'):
+ lineStr = lineStr.replace('>', '', 1)
+ else:
+ lineStr = lineStr.replace('>', '
')
newContent += '
Some other text.
" resultStr = htmlReplaceEmailQuote(testStr) if resultStr != expectedStr: - print('Result: ' + resultStr) + print('Result: ' + str(resultStr)) print('Expect: ' + expectedStr) assert resultStr == expectedStr @@ -2135,7 +2135,7 @@ def testReplaceEmailQuote(): "second lineSome question?
" resultStr = htmlReplaceEmailQuote(testStr) if resultStr != expectedStr: - print('Result: ' + resultStr) + print('Result: ' + str(resultStr)) print('Expect: ' + expectedStr) assert resultStr == expectedStr @@ -2146,15 +2146,10 @@ def testReplaceEmailQuote(): "> Text2Text7
" - expectedStr = "" + \ - "@somenick" + \ - "
Text1.
" + \ - "Text2
Text3
Text4
" + \ - "
Text5
Text6
Text7
" + expectedStr = "Text1.
Text2
Text3
>
Text4
Text5
Text6
Text7
" resultStr = htmlReplaceEmailQuote(testStr) if resultStr != expectedStr: - print('Result: ' + resultStr) + print('Result: ' + str(resultStr)) print('Expect: ' + expectedStr) assert resultStr == expectedStr