Python Forum

Full Version: single/double quote escapes codebox highlighter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
someone posted this...
    if s[0] == "'" and s[-1] == "'":
and i remember there was an issue regarding the string of the codebox escaping incorrectly. But i 1) cant find that thread and 2) dont remember if we fixed this issue or not?
I don't remember if we have looked at this or it has ever come up.
It's a rare case,usually it it's more code like this.
'a' and 'b'
1 and 2
'l' and '4'
'''c''' and '''d'''
'4' or '7'
# The rare case
'"' and '"'
'"' and '&'
So i don't know if digging into regex for this is worth it,can also mess up something else.
I know we've talked about it before, but I can't find where it's mentioned specifically.  Lots of highlighter threads, though.

I think the issue is related to multiple different quote characters near each other, like the highlighter loses track of which one is the enclosing quote, or something, and ends up highlighting too much.  I also think it might be specifically related to single quotes.
"'" and "'"
'"' and '"'
" ' " and " ' "
' " ' and ' " '
So it appears to only happen when you string a single or double quotation mark by itself.

I guess that would be a rare case of someone doing that. But it is surely annoying. I might be in agreement, that it might make it worse by tweaking the regex. But i also might think it might be worth trying to tweak if it happens more in the future.