PythonLexer: fix multiline string literals in brackets misidentified as docstrings by Gabrieljr42 · Pull Request #3417 · pygments/pygments · GitHub
Skip to content

PythonLexer: fix multiline string literals in brackets misidentified as docstrings - #3417

Open
Gabrieljr42 wants to merge 1 commit into
pygments:masterfrom
Gabrieljr42:fix/3025-multiline-string-docstring
Open

Gabrieljr42 wants to merge 1 commit into
pygments:masterfrom
Gabrieljr42:fix/3025-multiline-string-docstring

Conversation

@Gabrieljr42

Copy link
Copy Markdown

Fixes #3025.

Summary

String literals starting on a new line inside parentheses, brackets, or braces were previously recognized as String.Doc because they matched the root docstring regexes.

This PR tracks bracket nesting (expr-parens, expr-brackets, expr-braces) routing through expr-inside-brackets so that bracketed multiline strings remain regular string literals, while preserving true docstrings. Also adds fallback punctuation handling for unmatched closers in code fragments.

…as docstrings

String literals starting on a new line inside parentheses, brackets, or braces
were previously recognized as String.Doc because they matched the root docstring
regexes. Track bracket nesting in expr so bracketed multiline strings remain regular
string literals, while preserving true docstrings.

Fixes pygments#3025.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

error: extract comment from a string

1 participant