Skip to content

Commit 0f7a662

Browse files
authored
[misc] Fix previous change to <pre><code> (#18312)
Turns out that `<pre>...</pre>` blocks ignore the first empty line, but `<pre><code>...</code></pre>` blocks don't. So if we put the first real line of code on the html line after the tags, it will render as an empty line. (a problem that didn't exist for just pre tags) Let's remove those extra newlines after code tags. (I still think it's nice to have code tags for future syntax highlighting on the blog posts)
1 parent f078faa commit 0f7a662

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

misc/gen_blog_post_html.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ def format_code(h: str) -> str:
6262
else:
6363
r.append(a[i])
6464
i += 1
65-
return "\n".join(r)
65+
formatted = "\n".join(r)
66+
# remove empty first line for code blocks
67+
return re.sub(r"<code>\n", r"<code>", formatted)
6668

6769

6870
def convert(src: str) -> str:

0 commit comments

Comments
 (0)