sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[sql][python] #243

Closed vmuriart closed 8 years ago

vmuriart commented 8 years ago

I haven't been able to figure this one out even though I know its a simple regex edit. In the Python syntax definition to support embedded sql, I want to add an optional line break after the triple quotes to allow this to work

sql = """
SELECT A
       B,
       C,
FROM tableP
WHERE 1 = 1 """

currently only this one gets highlighted

sql = """SELECT A
       B,
       C,
FROM tableP
WHERE 1 = 1 """
FichteFoll commented 8 years ago

It's actually not that trivial due to how newlines affect the general tokenizing procedure, but still possible.

FichteFoll commented 8 years ago

Forgot to actually include the tip:

By pushing a different context that checks for the first non-whitespace character and if that marks the beginning of an SQL statement or query, you would set the SQL context, otherwise set the usual string context.

wbond commented 8 years ago

This should be resolved by 8e8831f13ba46f1a30a99d1114b8148e6a481a82

vmuriart commented 8 years ago

@wbond Thank you very much! just tested it, and it works! Though it seems to have introduced a small bug.

sql = """
    select colA
    from  tabs
"""

The opening """ isn't being colored and is left colored white. The closing one is still being colored correctly.