Update SourcesListLexer, fix #2695
For valid inputs, this new set of states is working as intended.
Input:
deb http://deb.debian.org/debian bookworm main contrib
deb [arch=amd64 trusted=yes] http://deb.debian.org/debian bookworm main contrib
Output:
# Line 1
Token.Keyword 'deb'
Token.Text.Whitespace ' '
Token.Literal.String 'http://deb.debian.org/debian'
Token.Text.Whitespace ' '
Token.Keyword 'bookworm'
Token.Text.Whitespace ' '
Token.Keyword.Pseudo 'main'
Token.Text.Whitespace ' '
Token.Keyword.Pseudo 'contrib'
Token.Text ''
Token.Text.Whitespace '\n'
# Line 2
Token.Keyword 'deb'
Token.Text.Whitespace ' '
Token.Literal.String.Other '[arch=amd64 trusted=yes]'
Token.Text.Whitespace ' '
Token.Literal.String 'http://deb.debian.org/debian'
Token.Text.Whitespace ' '
Token.Keyword 'bookworm'
Token.Text.Whitespace ' '
Token.Keyword.Pseudo 'main'
Token.Text.Whitespace ' '
Token.Keyword.Pseudo 'contrib'
Token.Text ''
Token.Text.Whitespace '\n'
I tried this and I don't see the improvement from this PR. I'm closing this unless there's some motivation as to why we should be doing this.
@Anteru Have you checked the linked issue?
I looked at the linked issue and it doesn't make it clearer for me either. We are not a parser, but a syntax highlighter, so adding semantics is secondary for us. Is the highlighting going to be substantially better with the changes?
@Anteru We're using Material for MkDocs for our documentation and there are quite some Debian sources.list examples.
Without this patch (i.e. latest version of pygments on PyPI):
With this patch:
At least the URL is highlighted correctly afterwards.
@Anteru Tests are now passing locally. I cannot run tox with -W error because there are two other warnings unrelated to this PR that would be promoted to errors:
ERROR tests/examplefiles - pytest.PytestRemovedIn9Warning: The (path: py.path.local) argument is deprecated, please use (file_path: pathlib.Path)
ERROR tests/snippets - pytest.PytestRemovedIn9Warning: The (path: py.path.local) argument is deprecated, please use (file_path: pathlib.Path)
One extra fix is chmod a-x pygments/lexers/gsql.py which I hope won't hurt.