Skip to content

Commit 9eef221

Browse files
committed
Switched from blackfriday to goldmark.
1 parent 6aa268a commit 9eef221

File tree

7 files changed

+44
-18
lines changed

7 files changed

+44
-18
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 1.2.3
4+
5+
* switched from blackfriday to goldmark
6+
37
## 1.2.2
48

59
* updated dependencies

demo/assets/entrypoint.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import "./mathjax";
12
import {message} from "./import/vars";
23

34
console.log(message);

demo/content/about/about.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,24 @@
44

55
Oogway is developed by the <a href="https://emvi.com" target="_blank">Emvi Software GmbH</a> based in Germany to simplify the process of developing custom websites.[^1]
66

7-
[^1]: Open-source and for free hosted on GitHub.
8-
97
* This is
10-
* a list.
8+
* a ~~list~~.
119

1210
1. And
1311
2. another
1412
3. list.
1513

14+
| Table | Column |
15+
| - | - |
16+
| Hello | World! |
17+
18+
- [ ] Check
19+
- [x] List
20+
21+
\\[V_{sphere} = \frac{4}{3}\pi r^3\\]
22+
23+
[^1]: Open-source and for free hosted on GitHub.
24+
1625
{{end}}
1726

1827
{{define "footer"}}

funcmap.go

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ package oogway
33
import (
44
"bytes"
55
"fmt"
6+
"github.com/Masterminds/sprig"
7+
"github.com/yuin/goldmark"
8+
"github.com/yuin/goldmark/extension"
69
"html/template"
710
"log"
811
"os"
912
"path/filepath"
1013
tt "text/template"
11-
12-
"github.com/Masterminds/sprig"
13-
"github.com/russross/blackfriday/v2"
1414
)
1515

1616
var (
@@ -100,14 +100,22 @@ func renderMarkdownBlock(file, block string, data any) template.HTML {
100100
}
101101

102102
func renderMarkdownContent(file, content, block string, data any) template.HTML {
103-
tpl, err := tt.New("").Funcs(tt.FuncMap(tplFuncMap)).Parse(content)
103+
tpl, err := tt.New("").Funcs(tplFuncMap).Parse(content)
104104

105105
if err != nil {
106106
log.Printf("Error parsing markdown file '%s': %s", file, err)
107107
return ""
108108
}
109109

110-
var buffer bytes.Buffer
110+
var buffer, out bytes.Buffer
111+
converter := goldmark.New(
112+
goldmark.WithExtensions(
113+
extension.NewFootnote(),
114+
extension.NewTable(),
115+
extension.Strikethrough,
116+
extension.TaskList,
117+
),
118+
)
111119

112120
if block != "" {
113121
if _, err := tpl.Parse(fmt.Sprintf(`{{template "%s" .}}`, block)); err != nil {
@@ -120,17 +128,21 @@ func renderMarkdownContent(file, content, block string, data any) template.HTML
120128
return ""
121129
}
122130

123-
return template.HTML(blackfriday.Run(buffer.Bytes(),
124-
blackfriday.WithExtensions(blackfriday.NoIntraEmphasis),
125-
blackfriday.WithExtensions(blackfriday.Footnotes)))
131+
if err := converter.Convert(buffer.Bytes(), &out); err != nil {
132+
panic(err)
133+
}
134+
135+
return template.HTML(out.String())
126136
}
127137

128138
if err := tpl.Execute(&buffer, data); err != nil {
129139
log.Printf("Error rendering markdown file '%s': %s", file, err)
130140
return ""
131141
}
132142

133-
return template.HTML(blackfriday.Run(buffer.Bytes(),
134-
blackfriday.WithExtensions(blackfriday.NoIntraEmphasis),
135-
blackfriday.WithExtensions(blackfriday.Footnotes)))
143+
if err := converter.Convert(buffer.Bytes(), &out); err != nil {
144+
panic(err)
145+
}
146+
147+
return template.HTML(out.String())
136148
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ require (
1111
github.com/fsnotify/fsnotify v1.6.0
1212
github.com/gorilla/mux v1.8.0
1313
github.com/pirsch-analytics/pirsch-go-sdk v1.8.0
14-
github.com/russross/blackfriday/v2 v2.1.0
1514
github.com/stretchr/testify v1.8.2
15+
github.com/yuin/goldmark v1.5.4
1616
)
1717

1818
require (

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
7676
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
7777
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
7878
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
79-
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
80-
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
8179
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
8280
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
8381
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -86,6 +84,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
8684
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
8785
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
8886
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
87+
github.com/yuin/goldmark v1.5.4 h1:2uY/xC0roWy8IBEGLgB1ywIoEJFGmRrX21YQcvGZzjU=
88+
github.com/yuin/goldmark v1.5.4/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
8989
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
9090
golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A=
9191
golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU=

oogway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const (
2323
\ \_______\ \_______\ \_______\ \____________\ \__\ \__\__/ / /
2424
\|_______|\|_______|\|_______|\|____________|\|__|\|__|\___/ /
2525
\|___|/
26-
v1.2.2`
26+
v1.2.3`
2727
)
2828

2929
var (

0 commit comments

Comments
 (0)