1. Georg Brandl
  2. pygments-main
  3. Pull requests

Pull requests

#331 Merged
Repository
Deleted repository
Branch
default (e6c5231613a0)
Repository
pygments-main
Branch
default

Move order of comment match after operator match

Author
  1. Gaurav Jain
Reviewers
Description

Since -- can be used in an operator, match operators before comments. The example file has been updated to add such an operator. Also the package-qualified import has been made more generic. This should resolve #975

  • Issues #975: Erroneous comment detection in Haskell resolved

Comments (7)

  1. Georg Brandl repo owner

    With this change, comments will not be matched as comments anymore, right?

    I think that the order is fine, but the comment regex must be amended to not allow further operator chars (except for minus) after the --, something like --($|[^:!#$%&*+.\\/<=>?@^|~].*$).

  2. Gaurav Jain author

    Comments are still properly matched since they are only matched at the end of the line with $ in the regex. So I'm not sure the change you are suggesting is needed, I tried even putting the line:

    (-->) = 2 -->implementation
    

    And pygments correctly does not classify the tail of the string as a comment

  3. Georg Brandl repo owner

    A little more context shows that this regex is in the "funclist" state, and isn't used in general for comments. See for example how this snippet is highlighted:

    import Test (a, b, -- c
    c, d)
    

    Here the "-- c" is a comment, but would be highlighted as an Operator.

    I also see that there is already a better regex in place for comments in the "root" state. This one just needs to be copied to the "funclist" state.

  4. Gaurav Jain author

    Alright, just testing out the various examples. Note that I do not think the example you posted is correct. There must be some whitespace before the 'c' operator.