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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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