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

HTML: No more auto-wrapping of overlong source code lines in printed media #9520

Closed
HeikoTheissen opened this issue Feb 27, 2024 · 1 comment
Labels

Comments

@HeikoTheissen
Copy link

HeikoTheissen commented Feb 27, 2024

Explain the problem.
Between releases 3.1.6 and 3.1.7, the generated CSS style for pre > code.sourceCode > span lost a display: inline-block rule, see this diff.

The print-specific rule

pandoc/test/lhs-test.html

Lines 180 to 183 in 104b3ba

@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}

is retained in 3.1.7, which is meant to produce hanging indentation of wrapped source code lines in printed media. However, without the display: inline-block, this has the effect of indenting the entire source code by 5em, rather than just the second and further lines.

Reproducible with the following markdown source file:

Look at my code:
```tex
This source code line is short.
This hopelessly overlong source code line will be automatically wrapped by pandoc.
```

When this is converted to HTML with the pandoc (3.1.7 or higher) command

pandoc -t html -o hanging.html -s hanging.md

and viewed with media type print emulated, it looks like

Look at my code:

        This source code line is short.
        This hopelessly overlong source code line will be automatically
wrapped by pandoc.

Note the unwanted indentation of both source code lines.

With pandoc 3.1.6 (where the CSS rule

pre > code.sourceCode > span { display: inline-block };

was still present), it looked better:

Look at my code:

This source code line is short.
This hopelessly overlong source code line will be automatically wrapped by
        pandoc.

The source code lines are not indented, but the second line is wrapped with hanging indentation.

The CSS rule

pre > code.sourceCode > span { display: inline-block };

should be retained at least for @media print.

Pandoc version?
Reproduced with

pandoc 3.1.11.1 on Windows 11
Features: +server +lua
Scripting engine: Lua 5.4

But the missing CSS rule

pre > code.sourceCode > span { display: inline-block };

affects all versions from 3.1.7 onwards.

@jgm
Copy link
Owner

jgm commented Feb 28, 2024

Here's the background on the change: #7248
(Btw the actual commit was in jgm/skylighting, where this CSS is defined.)

Re-adding

pre > code.sourceCode > span { display: inline-block };

for @print should be harmless and should fix this.

jgm added a commit to jgm/skylighting that referenced this issue Feb 28, 2024
See jgm/pandoc#7248 for an explanation of why this was removed
from the regular CSS, and see jgm/pandoc#9520 for an explanation
of the problems this causes in printed output.
@jgm jgm closed this as completed in 7504bf4 Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants