Skip to content

Commit

Permalink
develop quarkup engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Sup2point0 committed May 8, 2024
1 parent 39d80cb commit dc8bafe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 14 deletions.
2 changes: 1 addition & 1 deletion quarkdown/__version__.py
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion quarkdown/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 28 additions & 3 deletions quarkdown/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<link>` tag for loading fonts from Google Fonts.'''

return f'''<link rel="stylesheet" type="text/css" href="{url.google_fonts}{"&".join(font for font in fonts)}&display=swap">'''
return (
f'''<link rel="stylesheet" type="text/css" href="'''
f'''{url.google_fonts}{"&".join(url.fonts[font.lower] for font in fonts)}&display=swap">'''
)

def style(style: str) -> str:
'''Format the HTML `<link>` tag for a given stylesheet.'''

return f'''<link rel="stylesheet" type="text/css" href="{url.styles}/{style.lower()}">'''
style = style.lower()
if style == "auto":
style = "default"

return f'''<link rel="stylesheet" type="text/css" href="{url.styles}/{style}">'''


dec_index = {
"spring": 0.5,
Expand Down
12 changes: 5 additions & 7 deletions quarkdown/quarkify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand All @@ -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()
Expand All @@ -34,19 +35,16 @@ def render(file: ContentFile) -> dict:
header = load.get("header", "")
header = textualise.indent(header, 6)

styles = " \n".join(
f'''<link rel="stylesheet" type="text/css" '''
f'''href="https://raw.githack.com/Sup2point0/Quarkdown/main/quarkdown/resources/styles/{
"default" if style == "auto" else style.lower()}.css">'''
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")

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,
Expand Down
1 change: 0 additions & 1 deletion quarkdown/resources/core.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
<link rel="icon" type="image/x-icon" href="https://raw.githubusercontent.com/Sup2point0/Assort/origin/.assets/profiles/Purple Portal.png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Geologica:slnt,wght@-12..0,100..900&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Abel&display=swap"
{fonts}

<link rel="stylesheet" type="text/css" href="https://raw.githack.com/Sup2point0/supcode/sup/resources/Nova/Nova.css">
Expand Down

0 comments on commit dc8bafe

Please sign in to comment.