Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PS2 and backslash continuation #1672

Merged
merged 3 commits into from Jan 30, 2021
Merged

Conversation

mathiasertl
Copy link
Contributor

Fix backslash continuation and set PS2 to include a space (so > instead of >), which is the default for most (all) shells. Currently, lines that end with a backslash are always rendered verbatim, effectively breaking any actual examples that want to show the PS2 prompt correctly. Using a common bash session, this is how you would split a command into multiple lines:

$ ls --many options \
> /some/location

... where both $ and > would be the prompt (configured by the PS1 and PS2 environment variables). So naturally, we want these tokens to be shown as prompt (and also not be copy-able).

Current test cases also do not reflect this behavior. For example, the test_newline_in_echo has a fragment of '$ echo \\\nhi\nhi\n', which would be impossible to actually create (unless PS2 where configured to an empty string), as a user typing echo \<enter> would imediately get a > in the next line.

As an example, here is how this renders without the patch. Note how this is actually inverted: The > from the certbot command is not detected as a prompt (even though it actually it is), while for the echo command output is detected as a prompt, even though it actually it isn't:

without-patch

Now with the patch... it's actually correct:

with-patch

@Anteru Anteru merged commit a186efe into pygments:master Jan 30, 2021
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.

None yet

2 participants