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

Trim empty first lines of a code block #91

Open
PhalanxHead opened this issue Feb 27, 2022 · 1 comment
Open

Trim empty first lines of a code block #91

PhalanxHead opened this issue Feb 27, 2022 · 1 comment

Comments

@PhalanxHead
Copy link

Basically, when I use a code snippet like below, that I've likely pasted in from another document:

<pre>
<code>
fn main() {
    println!("Hello World"!);
}
</code>
</pre>

Line 1 (using hljs.initLineNumbersOnLoad();) will always be blank, as it registers the line break after the <code> tag as a new line.

It's easy enough to fix, it's just a little annoying.

Describe the solution you'd like
Optionally remove the first line from the code block if it's empty.

Describe alternatives you've considered
Technically you can do this:

<pre>
<code>fn main() {
    println!("Hello World"!);
}
</code>
</pre>

But it looks a little gross to me idk.

Not a high priority by any means, but I think it would feel nice :)

@wcoder
Copy link
Owner

wcoder commented Feb 28, 2022

It's the default behavior, more details: jekyll/jekyll-help#191

Whitespace inside <pre> elements is always respected by the browser, and output as-is. A newline is treated the same as any other whitespace character.

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

2 participants