forked from indymedia/epicyon
Replace quotes
parent
d58e4519d7
commit
323cb4a91b
17
content.py
17
content.py
|
@ -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
|
||||
|
||||
|
||||
|
|
4
tests.py
4
tests.py
|
@ -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">"test" 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():
|
||||
|
|
Loading…
Reference in New Issue