Pygments

generic syntax highlighter


Ticket #395 (closed defect: fixed)

Opened 13 months ago

Last modified 9 months ago

very minor failure in parsing Python

Reported by: guest Owned by: thatch
Priority: minor Milestone: 1.1
Component: lexers Keywords:
Cc:

Description

I ran a test file from python4ply against pygments as a stress test, because that file contains nearly every syntax construct I could find in Python. The result is at http://pygments.org/demo/1482/ .

It shows an extremely minor parsing bug. Python allows the following

def \
  f(): pass

but pygments highlights the "\", which I assume means there was a lexing error.

No one actually writes code like that so it's not like this is a serious problem.

Change History

Changed 9 months ago by thatch

  • milestone set to 1.1

Georg,

Any objections to changing the Python lexer to do:

            (r'(def)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'funcname'),
            (r'(class)((?:\s|\\\s)+)', bygroups(Keyword, Text), 'classname'),
            (r'(from)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
             'fromimport'),
            (r'(import)((?:\s|\\\s)+)', bygroups(Keyword.Namespace, Text),
             'import'),

Tim

Changed 9 months ago by thatch

  • owner changed from gbrandl to thatch
  • status changed from new to accepted

Available as [8055fb567f6d] in my branch.

Changed 9 months ago by thatch

  • status changed from accepted to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.