You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is problematic, because even though one can assign CSS properties to the go class, they will not have an effect on the actual line changes. For example, even when I assign user-select: none to class go, the user can still select and copy stray newlines between consecutive output lines, i.e., between consecutive spans.
Given that the lexer originally assigns Generic.Output to the whole line, including the newline character at the end, we can fix this by extending the line separator into the span itself, so the output becomes:
Until now, the HTML formatter first ends a span,
then adds the line separator:
<div class="highlight"><pre><span></span><span class="gp gp-VirtualEnv">(venv) </span><span class="gp">user:~$ </span>ssh-keygen
<span class="go">Generating public/private rsa key pair.</span>
<span class="go">[...]</span>
</pre></div>
This is problematic because it's not possible to match the line endings
when selecting for specific classes. For example, when selecting the
"go" class and setting user-select: none, the browser will still allow
the user to select and copy the newlines between consecutive output
lines, i.e., spans of class "go".
We can improve this by folding the line separator inside the span
itself, so the output becomes:
<div class="highlight"><pre><span></span><span class="gp gp-VirtualEnv">(venv) </span><span class="gp">user:~$ </span>ssh-keygen
<span class="go">Generating public/private rsa key pair.
</span><span class="go">[...]
</span></pre></div>
This does allow the attributes for specific classes to also extend to
the newline characters.
Closespygments#2499
Signed-off-by: Vangelis Koukis <evangelos.koukis@hpe.com>
Lexer "console" assigns class
go: Generic.Output
to lines that correspond to the output of commands.For example
However, the HTML formatter first ends a span of class
go
, then adds the line separator.This is problematic, because even though one can assign CSS properties to the
go
class, they will not have an effect on the actual line changes. For example, even when I assignuser-select: none
to classgo
, the user can still select and copy stray newlines between consecutive output lines, i.e., between consecutive spans.Given that the lexer originally assigns
Generic.Output
to the whole line, including the newline character at the end, we can fix this by extending the line separator into the span itself, so the output becomes:This does allow the attributes for class
go
to also extend to the newline characters, and makes things more predictable.Looking forward to your feedback, I can follow up with a PR that implements this behavior.
The text was updated successfully, but these errors were encountered: