diff --git a/blog.py b/blog.py
index ea527e3e0..8af540d80 100644
--- a/blog.py
+++ b/blog.py
@@ -202,15 +202,15 @@ def html_blog_post_markdown(content: str) -> str:
"""Converts any markdown to html
"""
replacements = {
- "># ": "h1",
- ">## ": "h2",
- ">### ": "h3",
- ">#### ": "h4",
- ">##### ": "h5",
- ">###### ": "h6"
+ "># ": "h3",
+ ">## ": "h4",
+ ">### ": "h5",
+ ">#### ": "h6",
+ ">##### ": "h7",
+ ">###### ": "h8"
}
new_content = content
- for markdown_text, _ in replacements.items():
+ for markdown_text, html_header in replacements.items():
if markdown_text not in new_content:
continue
sections = new_content.split(markdown_text)
@@ -222,9 +222,11 @@ def html_blog_post_markdown(content: str) -> str:
ctr += 1
continue
if '<' in section:
- section = '>' + section.replace('<', '<', 1)
+ section = '><' + html_header + '>' + \
+ section.replace('<', '' + html_header + '><', 1)
elif '\n' in section:
- section = '>' + section.replace('\n', '\n', 1)
+ section = '><' + html_header + '>' + \
+ section.replace('\n', '' + html_header + '>\n', 1)
else:
section = markdown_text + section
new_content2 += section
diff --git a/webapp_post.py b/webapp_post.py
index 32d9714a4..06f83a78b 100644
--- a/webapp_post.py
+++ b/webapp_post.py
@@ -3118,14 +3118,14 @@ def individual_post_as_html(signing_priv_key_pem: str,
# remove any tabs
content_str = \
content_str.replace('\t', '').replace('\r', '')
- # replace any markdown with html
- content_str = html_blog_post_markdown(content_str)
# Add bold text
if bold_reading and \
not post_is_blog:
content_str = bold_reading_string(content_str)
object_content = remove_header_tags(content_str)
+ # replace any markdown with html
+ content_str = html_blog_post_markdown(content_str)
object_content = \
remove_link_trackers_from_content(object_content)
object_content = \