Syntax style is configurable
Anirudh Oppiliappan x@icyphox.sh
Sat, 13 Feb 2021 12:53:02 +0530
3 files changed,
7 insertions(+),
6 deletions(-)
M
build.go
→
build.go
@@ -2,13 +2,13 @@ package main
import ( "fmt" - "html/template" "io/ioutil" "os" "os/exec" "path/filepath" "sort" "strings" + "text/template" "github.com/cross-cpm/go-shutil" )@@ -58,7 +58,7 @@ printErr(err)
} restContent, fm := parseFrontmatter(content) - bodyHtml := mdRender(restContent) + bodyHtml := mdRender(restContent, cfg) relPath, _ := filepath.Rel("pages/", mdPath) var buildPath string@@ -126,7 +126,7 @@ printErr(err)
} restContent, fm := parseFrontmatter(content) - bodyHtml := mdRender(restContent) + bodyHtml := mdRender(restContent, cfg) fm.Body = string(bodyHtml) var newFm = NewFm{
M
config.go
→
config.go
@@ -8,7 +8,7 @@
type Config struct { Title string `yaml:"title"` Header string `yaml:"header"` - DateFmt string `yaml:datefmt` + DateFmt string `yaml:"datefmt"` SiteURL string `yaml:"siteurl"` Description string `yaml:"description"` Author map[string]string `yaml:"author"`@@ -16,6 +16,7 @@ Footer string `yaml:"footer"`
Prebuild []string `yaml:"prebuild"` Postbuild []string `yaml:"postbuild"` RSSPrefixURL string `yaml:"rssprefixurl"` + Syntax string `yaml:"syntax"` } func parseConfig() Config {
M
markdown.go
→
markdown.go
@@ -11,12 +11,12 @@ var bfExts = bf.NoIntraEmphasis | bf.Tables | bf.FencedCode | bf.Autolink |
bf.Strikethrough | bf.SpaceHeadings | bf.BackslashLineBreak | bf.HeadingIDs | bf.Footnotes | bf.NoEmptyLineBeforeBlock -func mdRender(input []byte) []byte { +func mdRender(input []byte, cfg Config) []byte { return bf.Run( input, bf.WithRenderer( bfc.NewRenderer( - bfc.Style("bw"), + bfc.Style(cfg.Syntax), bfc.Extend( bf.NewHTMLRenderer(bf.HTMLRendererParameters{ Flags: bfFlags,