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

In Github, codeblock syntax-highlighting trims leading/trailing newlines #2

Open
EvitanRelta opened this issue Sep 20, 2022 · 0 comments

Comments

@EvitanRelta
Copy link
Owner

EvitanRelta commented Sep 20, 2022

In Github, codeblocks without syntax-highlighting preserves leading/trailing newlines:

```

const x

```


renders as:


const x


But when the language is specified, and theres syntax-highlighting, like:

```javascript

const x

```

it trims leading/trailing newlines when rendered:

const x

This CANNOT be circumvented with HTML-syntax like below. It still trims the newlines.

<pre lang="javascript"><code>

const x

</code></pre>

A possible fix would be to add 1 space to the front and back each, like:
(this example has double newlines on both ends, to show that u only need 1 space at the front and back)

```javascript
[SPACE]

const x

[SPACE]
```
@EvitanRelta EvitanRelta changed the title Codeblock syntax-highlighting trims leading/trailing newlines In Github, codeblock syntax-highlighting trims leading/trailing newlines Sep 20, 2022
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

1 participant