forked from indymedia/epicyon
Avoid adding quites within markup
parent
3c86717fc6
commit
5efc685220
19
content.py
19
content.py
|
@ -27,17 +27,20 @@ def htmlReplaceQuoteMarks(content: str) -> str:
|
||||||
|
|
||||||
newContent = ''
|
newContent = ''
|
||||||
openQuote = True
|
openQuote = True
|
||||||
noOfSections = len(sections)
|
markup = False
|
||||||
ctr = 0
|
for ch in content:
|
||||||
for s in sections:
|
currChar = ch
|
||||||
newContent += s
|
if ch == '<':
|
||||||
if ctr < noOfSections - 1:
|
markup = True
|
||||||
|
elif ch == '>':
|
||||||
|
markup = False
|
||||||
|
elif ch == '"' and not markup:
|
||||||
if openQuote:
|
if openQuote:
|
||||||
newContent += '<q>'
|
currChar = '<q>'
|
||||||
else:
|
else:
|
||||||
newContent += '</q>'
|
currChar = '</q>'
|
||||||
openQuote = not openQuote
|
openQuote = not openQuote
|
||||||
ctr += 1
|
newContent += currChar
|
||||||
return newContent
|
return newContent
|
||||||
|
|
||||||
|
|
||||||
|
|
4
tests.py
4
tests.py
|
@ -1938,6 +1938,10 @@ def runHtmlReplaceQuoteMarks():
|
||||||
result = htmlReplaceQuoteMarks(testStr)
|
result = htmlReplaceQuoteMarks(testStr)
|
||||||
assert result == '<q>hello</q>'
|
assert result == '<q>hello</q>'
|
||||||
|
|
||||||
|
testStr = '"hello" <a href="somesite.html">test html</a>'
|
||||||
|
result = htmlReplaceQuoteMarks(testStr)
|
||||||
|
assert result == '<q>hello</q> <a href="somesite.html">test html</a>'
|
||||||
|
|
||||||
|
|
||||||
def runAllTests():
|
def runAllTests():
|
||||||
print('Running tests...')
|
print('Running tests...')
|
||||||
|
|
Loading…
Reference in New Issue