Replace quotes

main
Bob Mottram 2020-08-02 20:16:22 +01:00
parent d58e4519d7
commit 323cb4a91b
2 changed files with 19 additions and 2 deletions

View File

@ -41,6 +41,23 @@ def htmlReplaceQuoteMarks(content: str) -> str:
currChar = ''
openQuote = not openQuote
newContent += currChar
if '"' in newContent:
openQuote = True
content = newContent
newContent = ''
ctr = 0
sections = content.split('"')
noOfSections = len(sections)
for s in sections:
newContent += s
if ctr < noOfSections - 1:
if openQuote:
newContent += ''
else:
newContent += ''
openQuote = not openQuote
ctr += 1
return newContent

View File

@ -1938,9 +1938,9 @@ def runHtmlReplaceQuoteMarks():
result = htmlReplaceQuoteMarks(testStr)
assert result == '“hello”'
testStr = '"hello" <a href="somesite.html">test html</a>'
testStr = '"hello" <a href="somesite.html">&quot;test&quot; html</a>'
result = htmlReplaceQuoteMarks(testStr)
assert result == '“hello” <a href="somesite.html">test html</a>'
assert result == '“hello” <a href="somesite.html">test html</a>'
def runAllTests():