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 jgm/pandoc#9292 #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Fix jgm/pandoc#9292 #193

wants to merge 1 commit into from

Conversation

lawcho
Copy link

@lawcho lawcho commented Jun 11, 2024

This PR aims to fix jgm/pandoc#9292

I'm not sure what the (-5 + 5) calculation was trying to do -- it was added in a commit about line numbers (#14), but doesn't seem to affect HTML rendering in firefox:

image

Weasyprint always renders the code better without:

image

Test source code:

<style>
body { columns: 2; }
div.sourceCode { border: 2pt solid black; }
.old {border: 1px solid red}
.new {border: 1px solid green}
.new pre > code.sourceCode > span {
  text-indent:  0 !important;
  padding-left: 0 !important;
}
</style>

:::: old

```{.haskell}
-- Here is some haskell code
-- which doesn't quite fit
-- into a 2-column layout
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
(bs >=> cs) a = do
  b <- bs a
  cs b
```

```{.haskell .numberLines}
-- Here is some haskell code
-- which doesn't quite fit
-- into a 2-column layout
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
(bs >=> cs) a = do
  b <- bs a
  cs b
```

::::

:::: new

```{.haskell}
-- Here is some haskell code
-- which doesn't quite fit
-- into a 2-column layout
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
(bs >=> cs) a = do
  b <- bs a
  cs b
```

```{.haskell .numberLines}
-- Here is some haskell code
-- which doesn't quite fit
-- into a 2-column layout
(>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
(bs >=> cs) a = do
  b <- bs a
  cs b
```

::::

HTML generated with pandoc test.md --standalone --pdf-engine weasyprint -o out.html

PDF generated with pandoc test.md --standalone --pdf-engine weasyprint -o out.pdf

@jgm
Copy link
Owner

jgm commented Jun 11, 2024

@dbaynard can you comment on what the +5 -5 is doing in the CSS?

pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }

This PR would remove it. I'm wondering if there are any potential bad consequences that I'm not seeing.

@dbaynard
Copy link
Contributor

Hanging indent. It means code with and without line numbers should align in the same position.

It doesn't appear to be working, though, from this example — I can dig out the original examples, if needed?

@jgm
Copy link
Owner

jgm commented Jun 11, 2024

It would be great to figure out whether this is doing anything important. If not, there's a benefit to removing it, as seen by the above case.

@dbaynard
Copy link
Contributor

OK, it's going to take me a week to make time for this. I see my PRs from 2017 onwards include some examples, so I'll check those.

@dbaynard
Copy link
Contributor

I've been delayed on this but it's on my list for July. Thanks for your patience.

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.

Too much indentation in highlighted code in Weasyprint
3 participants