TurtleLexer does not highlight triple quotes correctly

Issue #1404 new
Anonymous created an issue

Triple double quotes and triple single quotes highlight the remainder of the file as a String instead of just the string. The fix is simple: add quote marks to the appropriate regex within 'triple-double-quoted-string' and 'triple-single-quoted-string' for both TurtleLexer and SparqlLexer in rdf.py. Diff follows:

147c147 < (r'[^\]+', String),


        (r'[^"\\]+', String),

157c157 < (r'[^\]+', String),


        (r"[^'\\]+", String),

238c238 < (r'[^\]+', String),


        (r'[^"\\]+', String),

248c248 < (r'[^\]+', String),


        (r"[^'\\]+", String),

Comments (2)

  1. Justin Clark

    rdf.py (diff)

    147c147
    <             (r'[^\\]+', String),
    ---
    >             (r'[^"\\]+', String),
    157c157
    <             (r'[^\\]+', String),
    ---
    >             (r"[^'\\]+", String),
    238c238
    <             (r'[^\\]+', String),
    ---
    >             (r'[^"\\]+', String),
    248c248
    <             (r'[^\\]+', String),
    ---
    >             (r"[^'\\]+", String),
    
  2. Justin Clark

    rdf.py (excerpts)

    'triple-double-quoted-string': [
        (r'"""', String, 'end-of-string'),
        (r'[^"\\]+', String), # <-- This line changed! Double-quote added
        (r'\\', String, 'string-escape'),
    ],
    # ...
    'triple-single-quoted-string': [
        (r"'''", String, 'end-of-string'),
        (r"[^'\\]+", String), # <-- This line changed! Single-quote added
        (r'\\', String, 'string-escape'),
    ],
    
  3. Log in to comment