mirror of https://gitlab.com/bashrc2/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 = ''
|
||||
openQuote = True
|
||||
noOfSections = len(sections)
|
||||
ctr = 0
|
||||
for s in sections:
|
||||
newContent += s
|
||||
if ctr < noOfSections - 1:
|
||||
markup = False
|
||||
for ch in content:
|
||||
currChar = ch
|
||||
if ch == '<':
|
||||
markup = True
|
||||
elif ch == '>':
|
||||
markup = False
|
||||
elif ch == '"' and not markup:
|
||||
if openQuote:
|
||||
newContent += '<q>'
|
||||
currChar = '<q>'
|
||||
else:
|
||||
newContent += '</q>'
|
||||
currChar = '</q>'
|
||||
openQuote = not openQuote
|
||||
ctr += 1
|
||||
newContent += currChar
|
||||
return newContent
|
||||
|
||||
|
||||
|
|
4
tests.py
4
tests.py
|
@ -1938,6 +1938,10 @@ def runHtmlReplaceQuoteMarks():
|
|||
result = htmlReplaceQuoteMarks(testStr)
|
||||
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():
|
||||
print('Running tests...')
|
||||
|
|
Loading…
Reference in New Issue