Finished meta data with next and prev pages

This commit is contained in:
Kyler Olsen 2025-10-27 13:23:54 -06:00
parent 987940e91b
commit 6cf393121c
8 changed files with 20 additions and 23 deletions

View File

@ -11,7 +11,7 @@ def my_url_builder(label, base, end):
def convert_markdown_to_html(md_path: Path, html_path: Path): def convert_markdown_to_html(md_path: Path, html_path: Path):
html_path.parent.mkdir(parents=True, exist_ok=True) html_path.parent.mkdir(parents=True, exist_ok=True)
md = markdown.markdown(extensions=[ md = markdown.Markdown(extensions=[
WikiLinkExtension(base_url='./', end_url='.html', build_url=my_url_builder), WikiLinkExtension(base_url='./', end_url='.html', build_url=my_url_builder),
'tables', 'tables',
'fenced_code', 'fenced_code',
@ -20,14 +20,14 @@ def convert_markdown_to_html(md_path: Path, html_path: Path):
'meta', 'meta',
]) ])
html = md.convert(md_path.read_text(encoding="utf-8")) html = md.convert(md_path.read_text(encoding="utf-8"))
title = md.Meta["Title"] title = md.Meta["title"][0] # type: ignore
next_page = md.Meta["Next"] prev_page = md.Meta["prev"][0] # type: ignore
prev_page = md.Meta["Prev"] next_page = md.Meta["next"][0] # type: ignore
html_page = f"""<!DOCTYPE html> html_page = f"""<!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{md_path.stem}</title> <title>{title}</title>
<link rel="stylesheet" href="styles.css"> <link rel="stylesheet" href="styles.css">
</head> </head>
<body> <body>
@ -37,10 +37,10 @@ def convert_markdown_to_html(md_path: Path, html_path: Path):
<footer> <footer>
<div> <div>
<small> <small>
<span>&copy; 2025 Kyler Olsen</span> <span>&copy; 2025 Kyler Olsen</span> |
<a href="/">Home</a> | {f'<a href="/{my_url_builder(prev_page, './', '.html')}">Prev</a> |' if prev_page else ''}
<a href="/">Prev</a> <a href="/">Home</a>
<a href="/">Next</a> {f'| <a href="/{my_url_builder(next_page, './', '.html')}">Next</a>' if next_page else ''}
</small> </small>
</div> </div>
</footer> </footer>

View File

@ -1,5 +1,5 @@
--- ---
Title: YREA SLS | 4 Basic Operation Title: YREA SLS | 4 Basic Operations
Prev: Primitive Types Prev: Primitive Types
Next: Functions Next: Functions
--- ---

View File

@ -1,6 +1,6 @@
--- ---
Title: YREA SLS | 5 Functions Title: YREA SLS | 5 Functions
Prev: Basic Operation Prev: Basic Operations
Next: Control Flow Next: Control Flow
--- ---

View File

@ -1,9 +1,3 @@
---
Title: YREA SLS |
Prev:
Next:
---
--- ---
Title: YREA SLS | Specs Home Title: YREA SLS | Specs Home
Prev: Prev:

View File

@ -1,7 +1,7 @@
--- ---
Title: YREA SLS | F Memory Management Title: YREA SLS | F Memory Management
Prev: Module System Prev: Module System
Next: Examples & Tutorials Next: Examples and Tutorials
--- ---
## Appendix F: Memory Management (Future) ## Appendix F: Memory Management (Future)

View File

@ -1,7 +1,7 @@
--- ---
Title: YREA SLS | 1 Overview Title: YREA SLS | 1 Overview
Prev: Lexical Structure Prev: Index
Next: Index Next: Lexical Structure
--- ---
## 1. Overview ## 1. Overview

View File

@ -1,7 +1,7 @@
--- ---
Title: YREA SLS | 3 Primitive Types Title: YREA SLS | 3 Primitive Types
Prev: Lexical Structure Prev: Lexical Structure
Next: Basic Operation Next: Basic Operations
--- ---
## 3. Primitive Types ## 3. Primitive Types

View File

@ -31,10 +31,13 @@ class PrependNewLinePreprocessor(Preprocessor):
Each reference is prepended with a new line. Each reference is prepended with a new line.
''' '''
new_text = [] new_text = []
is_list = False
for line in lines: for line in lines:
if len(line) > 0: if len(line) > 0:
if (line[0].isdigit() or line[0] == '*') and line[len(line) - 1] != '*': if (line[0].isdigit() or line[0] == '-') and line[len(line) - 1] != '-':
line = '\n' + line if not is_list: line = '\n' + line
is_list = True
else: is_list = False
new_text.append(line) new_text.append(line)
return new_text return new_text