forked from indymedia/epicyon
Better handling of quotes
parent
7a5e915a57
commit
8565f362e6
41
content.py
41
content.py
|
@ -19,28 +19,29 @@ def htmlReplaceQuoteMarks(content: str) -> str:
|
||||||
"hello" becomes <q>hello</q>
|
"hello" becomes <q>hello</q>
|
||||||
"""
|
"""
|
||||||
if '"' not in content:
|
if '"' not in content:
|
||||||
return content
|
if '"' not in content:
|
||||||
|
return content
|
||||||
|
|
||||||
sections = content.split('"')
|
newContent = content
|
||||||
if len(sections) <= 2:
|
if '"' in content:
|
||||||
return content
|
sections = content.split('"')
|
||||||
|
if len(sections) > 1:
|
||||||
newContent = ''
|
newContent = ''
|
||||||
openQuote = True
|
openQuote = True
|
||||||
markup = False
|
|
||||||
for ch in content:
|
|
||||||
currChar = ch
|
|
||||||
if ch == '<':
|
|
||||||
markup = True
|
|
||||||
elif ch == '>':
|
|
||||||
markup = False
|
markup = False
|
||||||
elif ch == '"' and not markup:
|
for ch in content:
|
||||||
if openQuote:
|
currChar = ch
|
||||||
currChar = '“'
|
if ch == '<':
|
||||||
else:
|
markup = True
|
||||||
currChar = '”'
|
elif ch == '>':
|
||||||
openQuote = not openQuote
|
markup = False
|
||||||
newContent += currChar
|
elif ch == '"' and not markup:
|
||||||
|
if openQuote:
|
||||||
|
currChar = '“'
|
||||||
|
else:
|
||||||
|
currChar = '”'
|
||||||
|
openQuote = not openQuote
|
||||||
|
newContent += currChar
|
||||||
|
|
||||||
if '"' in newContent:
|
if '"' in newContent:
|
||||||
openQuote = True
|
openQuote = True
|
||||||
|
|
Loading…
Reference in New Issue