Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "shodo_ssg"
version = "0.0.dev4"
version = "0.0.1a1"
description = "A Python-based static site generator for building sites from Markdown and JSON files"
authors = [{name = "Ryan Phillips", email = "ryanphillipssoftware@gmail.com"}]
license = {text = "MIT"}
Expand Down
13 changes: 9 additions & 4 deletions shodo_ssg/data_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from json import load, loads
from abc import ABC, abstractmethod
from io import TextIOWrapper
from typing import TypedDict
from typing import Optional, TypedDict
from markdown2 import markdown


Expand All @@ -28,6 +28,7 @@ class SettingsDict(TypedDict):
images_path: str
styles_path: str
build_dir: str
markdown_header_ids: Optional[bool] = None


class DataLoader(ABC):
Expand Down Expand Up @@ -77,6 +78,7 @@ def __init__(self, settings: SettingsDict):
"""
super().__init__(settings["markdown_path"])
self.root_path = settings["root_path"]
self.markdown_header_ids = settings.get("markdown_header_ids", None)

def list_files(self, sub_dir="partials") -> list[tuple[str]]:
"""
Expand All @@ -103,9 +105,12 @@ def _convert_to_html(self, markdown_file: TextIOWrapper) -> str:
"""
Takes an open markdown file and converts it to an html string
"""
return markdown(
markdown_file.read(), extras=["fenced-code-blocks", "code-friendly"]
)
md_extras = ["fenced-code-blocks", "code-friendly"]

if self.markdown_header_ids:
md_extras.append("header-ids")

return markdown(markdown_file.read(), extras=md_extras)

def load_args(self):
"""
Expand Down
4 changes: 3 additions & 1 deletion shodo_ssg/project_template/build_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
"===The directory containing files and directories to be copied directly to the root of the build directory===": "",
"root_files_path": "src/root",
"===The output build directory===": "",
"build_dir": "dist"
"build_dir": "dist",
"===Enable or disable automatic generation of header IDs in markdown files===": "",
"markdown_header_ids": true
}
3 changes: 2 additions & 1 deletion tests/project_template/build_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"styles_path": "src/theme/static/styles",
"assets_path": "src/theme/static/assets",
"root_files_path": "src/root",
"build_dir": "dist"
"build_dir": "dist",
"markdown_header_ids": true
}