diff --git a/blog.py b/blog.py index 13ed6df..ea6302c 100644 --- a/blog.py +++ b/blog.py @@ -4,6 +4,8 @@ from datetime import datetime import markdown from markdown.extensions.codehilite import CodeHiliteExtension from markdown.extensions.fenced_code import FencedCodeExtension +from bs4 import BeautifulSoup +import re def list_blog_page_files(): @@ -22,12 +24,16 @@ def render_blog_page(date,handshake_scripts=None): with open(f"data/blog/{date}.md", "r") as f: content = f.read() # Get the title from the file name - title = date.removesuffix(".md").replace("_", " ").title() + title = date.removesuffix(".md").replace("_", " ") # Convert the md to html content = markdown.markdown(content, extensions=['sane_lists', 'codehilite', 'fenced_code']) # Add target="_blank" to all links content = content.replace(' tag containing numbered steps + paragraphs = soup.find_all('p') + for p in paragraphs: + content = p.decode_contents() + + # Check for likely numbered step structure + if re.search(r'1\.\s', content): + # Split into pre-list and numbered steps + # Match:
, optional whitespace, then a number and dot + parts = re.split(r'(?:)?\s*(\d+)\.\s', content) + + # Result: [pre-text, '1', step1, '2', step2, ..., '10', step10] + pre_text = parts[0].strip() + steps = parts[1:] + + # Assemble the ordered list + ol_items = [] + for i in range(0, len(steps), 2): + if i+1 < len(steps): + step_html = steps[i+1].strip() + ol_items.append(f"
  • {step_html}
  • ") + + # Build the final list HTML + ol_html = "
      \n" + "\n".join(ol_items) + "\n
    " + + # Rebuild paragraph with optional pre-text + new_html = f"{pre_text}
    \n{ol_html}" if pre_text else ol_html + + # Replace old

    with parsed version + new_fragment = BeautifulSoup(new_html, 'html.parser') + p.replace_with(new_fragment) + break # Only process the first matching

    + + return str(soup) def render_blog_home(handshake_scripts=None): diff --git a/data/resume.pdf b/data/resume.pdf index e6c02b6..438dd45 100644 Binary files a/data/resume.pdf and b/data/resume.pdf differ diff --git a/requirements.txt b/requirements.txt index a862d58..2dbd6c4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,4 +13,5 @@ solana solders weasyprint markdown -pygments \ No newline at end of file +pygments +beautifulsoup4 \ No newline at end of file diff --git a/server.py b/server.py index 5427250..c315cea 100644 --- a/server.py +++ b/server.py @@ -589,9 +589,9 @@ def index(): print("Error getting git data") # Get only repo names for the newest updates - if projects == [] or projectsUpdated < datetime.datetime.now() - datetime.timedelta( + if projects == [] or projectsUpdated < (datetime.datetime.now() - datetime.timedelta( hours=2 - ): + )).timestamp(): projectsreq = requests.get( "https://git.woodburn.au/api/v1/users/nathanwoodburn/repos" ) @@ -625,7 +625,7 @@ def index(): projects.append(projectsList[projectNum]) projectNames.append(projectsList[projectNum]["name"]) projectNum += 1 - projectsUpdated = datetime.datetime.now() + projectsUpdated = datetime.datetime.now().timestamp() custom = "" # Check for downtime diff --git a/templates/resume.html b/templates/resume.html index 94a3178..0df2a45 100644 --- a/templates/resume.html +++ b/templates/resume.html @@ -130,9 +130,9 @@

    Home Educated

    Self-Directed Learning