From dc8bafe0c40a1633d4d1c64de1299885e716d528 Mon Sep 17 00:00:00 2001 From: "Sup#2.0" <102817779+Sup2point0@users.noreply.github.com> Date: Wed, 8 May 2024 09:34:27 +0000 Subject: [PATCH] develop quarkup engine --- quarkdown/__version__.py | 2 +- quarkdown/deploy.py | 2 +- quarkdown/presets.py | 31 ++++++++++++++++++++++++++++--- quarkdown/quarkify.py | 12 +++++------- quarkdown/resources/core.html | 1 - suptools | 2 +- 6 files changed, 36 insertions(+), 14 deletions(-) diff --git a/quarkdown/__version__.py b/quarkdown/__version__.py index d4246d4..25ea4e8 100644 --- a/quarkdown/__version__.py +++ b/quarkdown/__version__.py @@ -1,3 +1,3 @@ '''Stores the `__version__` global constant for modules to track which version of Quarkdown they are using.''' -__version__ = "1.4.0" +__version__ = "1.5.0" diff --git a/quarkdown/deploy.py b/quarkdown/deploy.py index 74af96a..ff9a356 100644 --- a/quarkdown/deploy.py +++ b/quarkdown/deploy.py @@ -98,7 +98,7 @@ def export_and_deploy( continue try: - export = quarkify.render(file) + export = quarkify.render(file, {}) ### TODO track repo data path = export["path"] except quarkify.Quarkless: continue diff --git a/quarkdown/presets.py b/quarkdown/presets.py index e4c8bf8..2642ae3 100644 --- a/quarkdown/presets.py +++ b/quarkdown/presets.py @@ -2,20 +2,45 @@ Static resources. ''' + +class defaults: + fonts = ["abel", "montserrat"] + + class url: google_fonts = "https://fonts.googleapis.com/css2?" styles = "https://raw.githack.com/Sup2point0/Quarkdown/main/quarkdown/resources/styles" + fonts = { + "abel": "family=Abel", + "geologica": "Geologica:slnt,wght@-12..0,100..900", + "montserrat": "family=Montserrat:ital,wght@0,100..900;1,100..900", + "nanum": "family=Nanum+Pen+Script", + "outfit": "family=Outfit:wght@100..900", + "sen": "family=Sen:wght@400..800", + "shadows into light two": "family=Shadows+Into+Light+Two", + } + '''Google Fonts URLs.''' + + class css: - def font(fonts: list[str]) -> str: + def fonts(fonts: list[str]) -> str: '''Format the HTML `` tag for loading fonts from Google Fonts.''' - return f'''''' + return ( + f'''''' + ) def style(style: str) -> str: '''Format the HTML `` tag for a given stylesheet.''' - return f'''''' + style = style.lower() + if style == "auto": + style = "default" + + return f'''''' + dec_index = { "spring": 0.5, diff --git a/quarkdown/quarkify.py b/quarkdown/quarkify.py index afccbb3..dfef848 100644 --- a/quarkdown/quarkify.py +++ b/quarkdown/quarkify.py @@ -9,6 +9,7 @@ from github.ContentFile import ContentFile +from . import presets from . import textualise from .classes import Quarkless, ContextOpened, ExportFile from .__version__ import __version__ @@ -19,7 +20,7 @@ LIVE_LINES = 4 -def render(file: ContentFile) -> dict: +def render(file: ContentFile, repodata: dict) -> dict: '''Render Quarkdown-Flavoured Markdown to HTML, extracting content and metadata.''' text = base64.b64decode(file.content).decode() @@ -34,12 +35,8 @@ def render(file: ContentFile) -> dict: header = load.get("header", "") header = textualise.indent(header, 6) - styles = " \n".join( - f'''''' - for style in load.get("style", ["default"]) - ) + fonts = " \n".join(presets.css.fonts(repodata.get("fonts", presets.defaults.fonts))) + styles = " \n".join(presets.css.style(style) for style in load.get("style", ["default"])) root = os.path.split(os.path.abspath(__file__))[0] path = os.path.join(root, "resources/core.html") @@ -47,6 +44,7 @@ def render(file: ContentFile) -> dict: with open(path) as source: content = source.read().format( title = load.get("title", "Assort"), + fonts = presets.css.fonts(["abel", "geologica", "montserrat", "nanum"]), styles = styles, dark = load.get("duality", "light").lower(), header = header, diff --git a/quarkdown/resources/core.html b/quarkdown/resources/core.html index f9582a6..28624ce 100644 --- a/quarkdown/resources/core.html +++ b/quarkdown/resources/core.html @@ -11,7 +11,6 @@ - diff --git a/suptools b/suptools index e7c6990..425d473 160000 --- a/suptools +++ b/suptools @@ -1 +1 @@ -Subproject commit e7c69902b3cff71e167721d3cbfda08ec2a007b7 +Subproject commit 425d473d52fbce70e26d3bc494177edd6e961ebf