From afba0401fe90dd4f195cd4b566e4f5485c22af7f Mon Sep 17 00:00:00 2001 From: Valentin Stanciu <250871+svalentin@users.noreply.github.com> Date: Thu, 19 Dec 2024 16:01:17 +0000 Subject: [PATCH] [misc] Properly format subheadings and code in gen_blog_post_html.py Our Changelog is uses 3 number signs (#) for subheadings, not 4. This should generate proper `

` in the blog post. Also, code blocks are generate with just `
` tags. Let's also add
`` tags so we can potentially apply syntax highlighting with js
like highlight.js in the future, if we want to.
---
 misc/gen_blog_post_html.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/misc/gen_blog_post_html.py b/misc/gen_blog_post_html.py
index 7170696d5d09..2641ae1c466d 100644
--- a/misc/gen_blog_post_html.py
+++ b/misc/gen_blog_post_html.py
@@ -46,7 +46,7 @@ def format_code(h: str) -> str:
             indent = a[i].startswith("    ")
             if not indent:
                 i += 1
-            r.append("
")
+            r.append("
")
             while i < len(a) and (
                 (indent and a[i].startswith("    ")) or (not indent and not a[i].startswith("```"))
             ):
@@ -56,7 +56,7 @@ def format_code(h: str) -> str:
                     line = "    " + line
                 r.append(html.escape(line))
                 i += 1
-            r.append("
") + r.append("
") if not indent and a[i].startswith("```"): i += 1 else: @@ -76,7 +76,7 @@ def convert(src: str) -> str: h = re.sub(r"^## (Mypy [0-9.]+)", r"

\1 Released

", h, flags=re.MULTILINE) # Subheadings - h = re.sub(r"\n#### ([A-Z`].*)\n", r"\n

\1

\n", h) + h = re.sub(r"\n### ([A-Z`].*)\n", r"\n

\1

\n", h) # Sub-subheadings h = re.sub(r"\n\*\*([A-Z_`].*)\*\*\n", r"\n

\1

\n", h)