JSON syntax highlighting problems
The JSON spec supports the escaping of quotes with a backslash (
\). From http://json.org/ :
A string is a sequence of zero or more Unicode characters, wrapped in double quotes, using backslash escapes
However, it seems that the syntax highlighter ignores this:
I'm also puzzled by the fact that the highlighter sees a double forward slash (
//) as a comment since comments are not a part of the JSON spec.
@Webmaster4o , not related to your Pythonista question. But out of interest, have you looked at the JSON designer on iOS? Just interested in your opinion or make you aware of it
JSON Designer by Cribster
The Pythonista syntax highligher has some issues with escaped quotes in general. In Python, something like
"\""does not work properly either.
@dgelessus I don't see that issue at all:
Ah, I misremembered. Normal backslash escapes work, but a double-backslash before a quote is handled incorrectly. For example
"\\"is the string
\, but the syntax highlighter interprets the last backslash as escaping the quote and continues highlighting everything as part of the string.
I wasn't aware of the double-backslash issue in the Python highlighter, thanks.
@omz I think the JS highlighter also doesn't handle escaping in regex literals (the ones enclosed by slashes) though that's probably the same issue as with normal string literals. And for the multiple backslashes thing, can you check that it works for more than two backslashes too? I remember having used at least 8 in a row, and in any case we should be prepared for Ba'al the Soul Eater.
@omz The JS regex literals do look challenging to parse. I think they can also take regex flags as a prefix or suffix or something? It's a miracle that a feature like that can even be parsed at all.
The additional syntax-highlighted languages are great. HTML/CSS/JS are logical for Python-powered web servers, but other languages could be useful too, if only to read code in those languages. XML would be nice to have officially supported, at the moment if I need XML syntax highlighting I just add
.htmlto the file name. That works for the most part, except that
<?xml ...?>isn't highlighted and tags named
@omz Another quote highlighting issue: long bytes literals
br"""are highlighted like short literals, i. e. they do not continue into the next line. (The closing triple quote is of course detected, which means that the rest of the file is highlighted as a long string literal.)
Example (bug obviously only visible in Pythonista):
# normal code b""" bytes data, highlighted as code """ # normal code again, highlighted as literal