feat: move the blackfriday extension settings out of the render function, improve documentation
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja> git-svn-id: file:///srv/svn/repo/aya/trunk@72 cec141ff-132a-4243-88a5-ce187bd62f94
This commit is contained in:
@@ -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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"marisa.chaotic.ninja/aya"
|
"marisa.chaotic.ninja/aya"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Define global constants here
|
||||||
const (
|
const (
|
||||||
AYADIR = ".aya"
|
AYADIR = ".aya"
|
||||||
PUBDIR = ".pub"
|
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
|
// Renders markdown with the given layout into html expanding all the macros
|
||||||
func buildMarkdown(path string, w io.Writer, vars Vars) error {
|
func buildMarkdown(path string, w io.Writer, vars Vars) error {
|
||||||
v, body, err := getVars(path, vars)
|
v, body, err := getVars(path, vars)
|
||||||
|
extensions := blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.Strikethrough|blackfriday.Footnotes
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -186,7 +188,7 @@ func buildMarkdown(path string, w io.Writer, vars Vars) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
v["content"] = string(blackfriday.Run([]byte(content),
|
v["content"] = string(blackfriday.Run([]byte(content),
|
||||||
blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs|blackfriday.Strikethrough|blackfriday.Footnotes),
|
blackfriday.WithExtensions(extensions),
|
||||||
))
|
))
|
||||||
if w == nil {
|
if w == nil {
|
||||||
out, err := os.Create(filepath.Join(PUBDIR, renameExt(path, "", ".html")))
|
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
|
// 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 {
|
func build(path string, w io.Writer, vars Vars) error {
|
||||||
ext := filepath.Ext(path)
|
ext := filepath.Ext(path)
|
||||||
if ext == ".md" || ext == ".mkd" || ext == ".markdown" {
|
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) {
|
func buildAll(watch bool) {
|
||||||
lastModified := time.Unix(0, 0)
|
lastModified := time.Unix(0, 0)
|
||||||
modified := false
|
modified := false
|
||||||
@@ -391,6 +398,7 @@ func printUsage() {
|
|||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Main loop
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) == 1 {
|
if len(os.Args) == 1 {
|
||||||
printUsage()
|
printUsage()
|
||||||
|
|||||||
5
doc.go
5
doc.go
@@ -1,4 +1,3 @@
|
|||||||
package aya
|
|
||||||
// Package aya is [...]
|
// Package aya is [...]
|
||||||
|
|
||||||
// Aya is the fastest static site generator
|
// 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 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
|
// This one (re)incorporates the features removed in the former from the latter
|
||||||
|
|
||||||
|
// Copyright (c) 2014 Serge Zaitsev
|
||||||
|
// Copyright (c) 2023 Izuru Yakumo
|
||||||
|
|
||||||
// Ayaya~
|
// Ayaya~
|
||||||
|
package aya
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// This is used for setting build-time variables
|
||||||
package aya
|
package aya
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
Reference in New Issue
Block a user