Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formatters/html: Fold newlines into spans
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. Closes pygments#2499 Signed-off-by: Vangelis Koukis <evangelos.koukis@hpe.com>
- Loading branch information