diff --git a/layouts/shortcodes/code-toggle.html b/layouts/shortcodes/code-toggle.html
index 0b92d520d..6d4246052 100644
--- a/layouts/shortcodes/code-toggle.html
+++ b/layouts/shortcodes/code-toggle.html
@@ -29,7 +29,7 @@
{{ range $langs }}
- {{ highlight ($code | transform.Remarshal . | safeHTML) . ""}}
+ {{ highlight ($code | transform.Remarshal . | replaceRE `\n+` "\n" | safeHTML) . "" }}
{{ if ne ($.Get "copy") "false" }}
@@ -37,5 +37,5 @@
{{end}}
{{ end }}
-
+