11ty / eleventy-plugin-syntaxhighlight

A pack of Eleventy plugins for syntax highlighting in Markdown, Liquid, and Nunjucks templates.
https://www.11ty.dev/docs/plugins/syntaxhighlight/
MIT License
129 stars 32 forks source link

Support multiple consecutive line breaks in code snippets #5

Closed mathiasbynens closed 6 years ago

mathiasbynens commented 6 years ago

Previously, repeated consecutive line breaks got eaten by this syntax highlighter plugin.

Consider this imaginary code snippet:

```
foo

bar
```

The empty line got turned into an empty <div class="highlight-line"></div>, which is a form of data loss — the actual line break is no longer part of the resulting HTML. This caused it to render differently, too.

This patch ensures newlines are preserved by explicitly inserting them in the resulting HTML when needed consistently.

mathiasbynens commented 6 years ago

See https://github.com/11ty/eleventy-base-blog/pull/21 for an actual example.

zachleat commented 6 years ago

Thanks!