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

Not the good number of lines #1946

Closed
lcswillems opened this issue Jun 18, 2019 · 7 comments · Fixed by PrismJS/prism-themes#79
Closed

Not the good number of lines #1946

lcswillems opened this issue Jun 18, 2019 · 7 comments · Fixed by PrismJS/prism-themes#79

Comments

@lcswillems
Copy link

Hi,

I tried the line numbers plugin. However, with the following code:

<pre class="line-numbers"><code class="language-latex">\section{Hi}

\begin{itemize}
\item Hi
\end{itemize}</code></pre>

I get the following output:

image

Any idea?

@lcswillems
Copy link
Author

There is the good number!! I just don't have the good line height. Sorry for that!

@lcswillems
Copy link
Author

lcswillems commented Jun 18, 2019

However, how can I change the line height of the line numbers?

@RunDevelopment
Copy link
Member

It's important that both the pre and code elements have the same line height. You don't seem to use one of Prism's default themes, so I guess that that's the issue.

Btw. What theme is that?

@lcswillems
Copy link
Author

lcswillems commented Jun 18, 2019

It is the Github theme: https://github.com/PrismJS/prism-themes/blob/master/themes/prism-ghcolors.css

This is strange because, with the default theme, the line numbers have the good line-height but with this theme they don't...

@RunDevelopment
Copy link
Member

Alright. The problem is the following line:

code[class*="language-"],
pre[class*="language-"] {
    ...
    font-size: 0.95em;
    ...
}

This means that for a code block <pre><code>, the font size of pre and code is 95% of their parent. The parent of code is pre, so effectively, the code will be displayed at 90.25% font size.

I don't quite get why, but just enforcing that the font size of code is 100% fixes the issue.
I'll make a PR with the fix.

@lcswillems
Copy link
Author

In fact, your fix works for me!

Thank you :)

@mAAdhaTTah
Copy link
Member

Going to close this issue, since the fix is in prism-themes.

mAAdhaTTah pushed a commit to PrismJS/prism-themes that referenced this issue Sep 24, 2019
This fixes [prism#1946](PrismJS/prism#1946).

The problem was that the `<code>` element nested inside the `<pre>` element has to have the same font size as the `pre`.  I added a little rule to nearly every theme to enforce just this.

```css
pre > code[class*="language-"] {
	font-size: 1em;
}
```

---

This also enforces tabs for indentation for all theme.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants