> And what's so special about SQL over, say, regular expressions, XML,
> JSON, YAML, Markdown, ReST, LaTeX, etc? I might want to use the s''
> prefix for embedded Scheme code rather than SQL.
Um, regular expressions are not precisely the best example there, since
we do have raw strings specifically for regular expressions.
I mentioned them also in my similar list, but deliberately. *Raw strings* are not per-se for regexen, even if that is one of the more common uses. That said, I wonder why no text editors I know of try special highlighting of `r"..."` strings. We already (often) have that hint that the quoted thing might be a regular expression. Maybe it's just that those patterns are so densely coded that adding colors doesn't really help.
Doing a search, the only editor I find easily that seems to highlight regexen is JetBrains Rider. The examples it shows look kinda-sorta useful. Probably someone made a plugin or something that does it elsewhere.
Here's another idea that is purely convention, as the comment convention is. Use functions! They are just cruft from a runtime point-of-view, but they provide a really obvious hint to IDEs or other tools:
SQL = REGX = XPATH = MD = lambda s: s
pat = REGX(r"\$\d{1,10}.\d{2}")
sql = SQL("SELECT foo, bar FROM table WHERE baz > 42;")
query = XPATH("/bookstore/book[1]/title")
These decorations are doing nothing functionally, but they would be easy for any IDE that wanted to to look for. This is completely extensible to any mini-language that might occur in strings. You'd just need some sort of configuration for the editor to know how to look for and highlight each syntax.
I kinda like the look of this better than the end of line comment (which gets more complex to figure out with multi-line, triple-quoted strings. The function just handles that automatically. Of course, those functions *could* do something more than identity if they wanted to.