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

Code block formatting surprise #92

Closed
jcw opened this issue Oct 23, 2019 · 7 comments
Closed

Code block formatting surprise #92

jcw opened this issue Oct 23, 2019 · 7 comments

Comments

@jcw
Copy link

jcw commented Oct 23, 2019

Hello - while trying out this theme, I ran into some unexpected behaviour: line formatting jumps around considerably when using different ways to delimit code blocks:

  1. using '''sh (backticks, that is, but I'm having trouble escaping them here)
  2. using {{< highlight sh "hl_lines=8 15-17" >}}
  3. using {{< highlight sh "linenos=table,hl_lines=8 15-17" >}}

I don't mean the line numbering or highlights, but the fact that the layout / line spacing varies considerably between these different methods. It should be possible to reproduce this, by editing creating-a-new-theme.md in the example site.

I'm using Hugo v0.59.0.

@alex-shpak
Copy link
Owner

Hi!
Thank you for report, I think most things can be aligned there. Mostly line-height and paddings fixes. I will dedicate some time after search and language changes. PR is welcome.

@jcw
Copy link
Author

jcw commented Oct 24, 2019

Thanks, it's a lovely theme for use with Hugo.

@oshliaer
Copy link
Contributor

I've created samples and codes

```sh
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
```

1572118798909

{{< highlight sh "hl_lines=8 15-17" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}

1572118887830

{{< highlight sh "linenos=table,hl_lines=8 15-17" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}

1572118926515

All pictures have discrepancies.

@alex-shpak
Copy link
Owner

I pushed some changes, it's not pixel-perfect but near
image

@oshliaer
Copy link
Contributor

OK. It seems there is a small adjusting yet

No shortcode. Height of the block is 307px. OK
```sh
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
```
Shortcode. Height of the block is 307px. OK
{{< highlight sh >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}
Shortcode with FOUR highlight lines. Height of the block is 295px. 12 px reduction!
{{< highlight sh "hl_lines=3 8-10" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}
Shortcode with FOUR highlight numbers lines. Height of the block is 295px. 12 px reduction!
{{< highlight sh "linenos=table,hl_lines=3 8-10" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}
Shortcode with ONE highlight line. Height of the block is 304px. 3px reduction!
{{< highlight sh "hl_lines=3" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}
Shortcode with TWO highlight lines in order. Height of the block is 301px. 6px reduction!
{{< highlight sh "hl_lines=3-4" >}}
#!/bin/bash

echo "Enter directory name"
read ndir
if [ -d "$ndir" ]
then
  echo "Directory exist"
else
  `mkdir $ndir`
  echo "Directory created"
fi
{{< / highlight >}}

@alex-shpak It looks like each highlighted line eats up 3px.

@alex-shpak
Copy link
Owner

Yes, it's due to highlighted lines having display:block style which is affecting line-height.
I can set line-height to em units. Though, there will be still +- pixel gap per highlighted block because of subpixel calculation.

@jcw
Copy link
Author

jcw commented Oct 27, 2019

Great progress! Minor pixel differences should be of no concern - nobody is going to toggle quickly between the two. It was just the large jumps which surprised me, and the fact that nobody seemed to have noticed / looked into this until now.

Many thanks for the fixes, I think this issue can be closed now.

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

No branches or pull requests

3 participants