]> Nishi Git Mirror - aya.git/commitdiff
Add support for bfchroma syntax highlighting 0.5.8
authorIzuru Yakumo <yakumo.izuru@chaotic.ninja>
Mon, 8 May 2023 21:10:36 +0000 (18:10 -0300)
committerIzuru Yakumo <yakumo.izuru@chaotic.ninja>
Mon, 8 May 2023 21:10:36 +0000 (18:10 -0300)
Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>
README.md
cmd/aya/main.go
go.mod
go.sum

index dc641366fc808bd6de8ad4f1fe8cafe2a7e8358b..965aa713f10f37d6ccbcd44d71602c5db78e86eb 100644 (file)
--- a/README.md
+++ b/README.md
@@ -11,6 +11,7 @@ Named after [Aya Shameimaru](https://en.touhouwiki.net/wiki/Aya_Shameimaru) from
 * Highly extensible
 * Works well for blogs and generic static websites (landing pages etc)
 * Easy to learn
+* Code highlighting with [bfchroma](https://github.com/Depado/bfchroma)
 * Fast (duh!)
 
 ## Installation
index b242692ca487238b22e1c3e5c7f3d0ee3bdaceed..0c672dda513a7552e179c2c08263a7b06776bfc6 100644 (file)
@@ -1,4 +1,4 @@
-// $TheSupernovaDuo: cmd/aya/main.go,v 0.5.x 2023/5/7 10:57:10 yakumo_izuru Exp $
+// $TheSupernovaDuo: cmd/aya/main.go,v 0.5.x 2023/5/8 18:6:18 yakumo_izuru Exp $
 package main
 
 import (
@@ -19,6 +19,7 @@ import (
        log "github.com/sirupsen/logrus"
        "github.com/eknkc/amber"
        "github.com/yosssi/gcss"
+       "github.com/Depado/bfchroma/v2"
 )
 
 const (
@@ -185,9 +186,8 @@ func buildMarkdown(path string, w io.Writer, vars Vars) error {
        if err != nil {
                return err
        }
-       v["content"] = string(blackfriday.Run(
-               []byte(content),
-               blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs),
+       v["content"] = string(blackfriday.Run([]byte(content),
+               blackfriday.WithExtensions(blackfriday.CommonExtensions|blackfriday.AutoHeadingIDs),blackfriday.WithRenderer(bfchroma.NewRenderer()),
        ))
        if w == nil {
                out, err := os.Create(filepath.Join(PUBDIR, renameExt(path, "", ".html")))
diff --git a/go.mod b/go.mod
index 7ef39dff4a490d047f227726f0f34f594267c869..754efb9dcab152dda4400e29ac70ab44d64eccf0 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -3,6 +3,7 @@ module marisa.chaotic.ninja/aya
 go 1.17
 
 require (
+       github.com/Depado/bfchroma/v2 v2.0.0
        github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385
        github.com/russross/blackfriday/v2 v2.1.0
        github.com/sirupsen/logrus v1.9.0
@@ -10,4 +11,8 @@ require (
        gopkg.in/yaml.v2 v2.4.0
 )
 
-require golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
+require (
+       github.com/alecthomas/chroma/v2 v2.2.0 // indirect
+       github.com/dlclark/regexp2 v1.4.0 // indirect
+       golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
+)
diff --git a/go.sum b/go.sum
index 35c55c6cf25f1ec1e5551c3a23c427ad913fff13..7d4482dfadc82a68cccda404fe63d2dbb891a66a 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -1,6 +1,14 @@
+github.com/Depado/bfchroma/v2 v2.0.0 h1:IRpN9BPkNwEpR6w1ectIcNWOuhDSLx+8f1pn83fzxx8=
+github.com/Depado/bfchroma/v2 v2.0.0/go.mod h1:wFwW/Pw8Tnd0irzgO9Zxtxgzp3aPS8qBWlyadxujxmw=
+github.com/alecthomas/chroma/v2 v2.2.0 h1:Aten8jfQwUqEdadVFFjNyjx7HTexhKP0XuqBG67mRDY=
+github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
+github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae h1:zzGwJfFlFGD94CyyYwCJeSuD32Gj9GTaSi5y9hoVzdY=
+github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
+github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
 github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385 h1:clC1lXBpe2kTj2VHdaIu9ajZQe4kcEY9j0NsnDDBZ3o=
 github.com/eknkc/amber v0.0.0-20171010120322-cdade1c07385/go.mod h1:0vRUJqYpeSZifjYj7uP3BG/gKcuzL9xWVV/Y+cK33KM=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=