diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2024-03-27 22:50:25 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-27 22:50:25 -0600 |
commit | 721c68798ec957b7874ebe8b0525b20375f8ce37 (patch) | |
tree | b2813c98907fc7268252f0ab038ed92c812f7a89 /generate_me.py | |
parent | 9e620084e57378952c1a7f8e0a772ebebd18932b (diff) | |
parent | 01ff93c9c16867216f2d249664803860e1d6d5eb (diff) |
Merge pull request #18 from navanchauhan/hyde-theme-port
Hyde theme port
Diffstat (limited to 'generate_me.py')
-rw-r--r-- | generate_me.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/generate_me.py b/generate_me.py index fa39bf9..736cece 100644 --- a/generate_me.py +++ b/generate_me.py @@ -1,4 +1,4 @@ -from markdown2 import Markdown +from markdown3 import Markdown import os from jinja2 import Environment, FileSystemLoader from distutils.dir_util import copy_tree @@ -7,6 +7,8 @@ import email.utils from helper_libs.image_utils import ImageText from PIL import Image +import re + templates = Environment(loader=FileSystemLoader("templates")) src_folder = "Content" out_folder = "docs" @@ -28,9 +30,13 @@ md = Markdown( "task_list", "tables", "target-blank-links", + "header-ids", + "latex", ] ) +# h1 tag regex ignoring any attributes +h1_tag = re.compile(r"<h1[^>]*>(.*?)</h1>") def render_markdown_post( html, metadata=None, template="post.html", posts=[], title=None @@ -83,7 +89,7 @@ for x in os.walk(src_folder): fpath = os.path.join(x[0], y) with open(fpath) as f: _html = md.convert(f.read()) - _post_title = _html[4 : _html.find("</h1>")] + _post_title = re.search(h1_tag, _html).group(1) _post = _html.metadata _post["title"] = _post_title _post["link"] = fpath.replace(src_folder, "").replace( |