Mercurial > yakumo_izuru > aya
changeset 71:7819959ac6ca draft
feat: move the blackfriday extension settings out of the render function, improve documentation
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
author | yakumo.izuru |
---|---|
date | Tue, 03 Oct 2023 02:39:08 +0000 |
parents | 00b02728b74f |
children | b32ca33188c0 |
files | cmd/aya/main.go doc.go version.go |
diffstat | 3 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/cmd/aya/main.go Thu Sep 28 01:46:46 2023 +0000 +++ b/cmd/aya/main.go Tue Oct 03 02:39:08 2023 +0000 @@ -1,4 +1,4 @@ -// $TheSupernovaDuo: cmd/aya/main.go,v 0.6.3 2023/09/27 22:46:30 yakumo_izuru Exp $ +// $TheSupernovaDuo: marisa.chaotic.ninja/aya/cmd/aya, v 1.0 2023-10-03 02:34:17, yakumo_izuru Exp $ package main import ( @@ -21,6 +21,7 @@ "marisa.chaotic.ninja/aya" ) +// Define global constants here const ( AYADIR = ".aya" PUBDIR = ".pub" @@ -178,6 +179,7 @@ // Renders markdown with the given layout into html expanding all the macros func buildMarkdown(path string, w io.Writer, vars Vars) error { v, body, err := getVars(path, vars) + extensions := blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.Strikethrough|blackfriday.Footnotes if err != nil { return err } @@ -186,7 +188,7 @@ return err } v["content"] = string(blackfriday.Run([]byte(content), - blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.Strikethrough|blackfriday.Footnotes), + blackfriday.WithExtensions(extensions), )) if w == nil { out, err := os.Create(filepath.Join(PUBDIR, renameExt(path, "", ".html"))) @@ -302,6 +304,8 @@ } // This function passes the files to build to their corresponding functions +// As far as I'm aware, Markdown has three possible filename extensions, +// but .md is the most common one known. func build(path string, w io.Writer, vars Vars) error { ext := filepath.Ext(path) if ext == ".md" || ext == ".mkd" || ext == ".markdown" { @@ -317,6 +321,9 @@ } } +// Build everything and store it on PUBDIR +// If boolean watch is true, it keeps on going +// every time you modify something. func buildAll(watch bool) { lastModified := time.Unix(0, 0) modified := false @@ -391,6 +398,7 @@ os.Exit(0) } +// Main loop func main() { if len(os.Args) == 1 { printUsage()
--- a/doc.go Thu Sep 28 01:46:46 2023 +0000 +++ b/doc.go Tue Oct 03 02:39:08 2023 +0000 @@ -1,4 +1,3 @@ -package aya // Package aya is [...] // Aya is the fastest static site generator @@ -17,4 +16,8 @@ // This is a hard fork of git.mills.io/prologic/zs, which in turn is a fork of zserge's zs // This one (re)incorporates the features removed in the former from the latter +// Copyright (c) 2014 Serge Zaitsev +// Copyright (c) 2023 Izuru Yakumo + // Ayaya~ +package aya