Replace quotes

main
Bob Mottram 2020-08-02 19:09:50 +01:00
parent a0c6dd9374
commit 853ef7af2e
2 changed files with 6 additions and 6 deletions

View File

@ -36,9 +36,9 @@ def htmlReplaceQuoteMarks(content: str) -> str:
markup = False
elif ch == '"' and not markup:
if openQuote:
currChar = '<q>'
currChar = ''
else:
currChar = '</q>'
currChar = ''
openQuote = not openQuote
newContent += currChar
return newContent
@ -639,7 +639,7 @@ def addHtmlTags(baseDir: str, httpPrefix: str,
if longWordsList:
content = removeLongWords(content, maxWordLength, longWordsList)
content = content.replace(' --linebreak-- ', '</p><p>')
return '<p>' + content + '</p>'
return '<p>' + htmlReplaceQuoteMarks(content) + '</p>'
def getMentionsFromHtml(htmlText: str,

View File

@ -1928,7 +1928,7 @@ def runHtmlReplaceQuoteMarks():
print('htmlReplaceQuoteMarks')
testStr = 'The "cat" "sat" on the mat'
result = htmlReplaceQuoteMarks(testStr)
assert result == 'The <q>cat</q> <q>sat</q> on the mat'
assert result == 'The “cat” “sat” on the mat'
testStr = 'The cat sat on the mat'
result = htmlReplaceQuoteMarks(testStr)
@ -1936,11 +1936,11 @@ def runHtmlReplaceQuoteMarks():
testStr = '"hello"'
result = htmlReplaceQuoteMarks(testStr)
assert result == '<q>hello</q>'
assert result == '“hello”'
testStr = '"hello" <a href="somesite.html">test html</a>'
result = htmlReplaceQuoteMarks(testStr)
assert result == '<q>hello</q> <a href="somesite.html">test html</a>'
assert result == '“hello” <a href="somesite.html">test html</a>'
def runAllTests():