From: Izuru Yakumo Date: Tue, 3 Oct 2023 02:39:08 +0000 (-0300) Subject: feat: move the blackfriday extension settings out of the render function, improve... X-Git-Tag: 0.6.4~1 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=473189de4f0f928cba6ab437e1391e3742a4b201;p=aya.git feat: move the blackfriday extension settings out of the render function, improve documentation Signed-off-by: Izuru Yakumo --- diff --git a/cmd/aya/main.go b/cmd/aya/main.go index 805c51e..9ade991 100644 --- a/cmd/aya/main.go +++ b/cmd/aya/main.go @@ -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 @@ import ( "marisa.chaotic.ninja/aya" ) +// Define global constants here const ( AYADIR = ".aya" PUBDIR = ".pub" @@ -178,6 +179,7 @@ func render(s string, vars Vars) (string, error) { // 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 @@ func buildMarkdown(path string, w io.Writer, vars Vars) error { 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 @@ func buildRaw(path string, w io.Writer) error { } // 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 @@ func build(path string, w io.Writer, vars Vars) error { } } +// 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 @@ func printUsage() { os.Exit(0) } +// Main loop func main() { if len(os.Args) == 1 { printUsage() diff --git a/doc.go b/doc.go index da7bc6d..f4c5df3 100644 --- a/doc.go +++ b/doc.go @@ -1,4 +1,3 @@ -package aya // Package aya is [...] // Aya is the fastest static site generator @@ -17,4 +16,8 @@ package aya // 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 diff --git a/version.go b/version.go index abbbb4a..b518c11 100644 --- a/version.go +++ b/version.go @@ -1,3 +1,4 @@ +// This is used for setting build-time variables package aya import (