fuck goldmark

This commit is contained in:
Ben Visness 2022-09-01 22:02:59 -05:00
parent 98b9ef6589
commit 5b1bf5951a
4 changed files with 17 additions and 2 deletions

Binary file not shown.

View File

@ -7,6 +7,7 @@ import (
"git.handmade.network/hmn/hmn/src/hmnurl"
"git.handmade.network/hmn/hmn/src/oops"
"git.handmade.network/hmn/hmn/src/utils"
"github.com/alecthomas/chroma"
chromahtml "github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/lexers"
@ -117,6 +118,15 @@ func init() {
return htm("a", attrs{"href": hmnurl.BuildEducationGlossary(term), "class": "glossary-term", "data-term": term}), true
})
addSimpleTag(education, "note", "div", false, attrs{"class": "education-note"})
addTag(education, "resource", func(bn *bbcode.BBCodeNode) (*bbcode.HTMLTag, bool) {
name, _ := bn.GetOpeningTag().Args["name"]
url, _ := bn.GetOpeningTag().Args["url"]
res := htm("a", attrs{"class": "education-resource", "href": url, "target": "_blank"},
htm("h2", nil, bbcode.NewHTMLTag(utils.OrDefault(name, `hey you, do name="Some Resource" url="whatever"`))),
)
return res, true
})
}
type attrs map[string]string

View File

@ -76,6 +76,11 @@ func main() {
assert.Equal(t, 1, strings.Count(html, "<div"))
assert.Contains(t, html, `class="education-note"`)
})
t.Run("[resource]", func(t *testing.T) {
html := ParseMarkdown(`[resource name="cool name" url="blep"]Excellent description.[/resource]`, EducationRealMarkdown)
t.Log(html)
t.Fail()
})
})
}

View File

@ -1,5 +1,5 @@
<!DOCTYPE html{{ if .OpenGraphItems }} prefix="og: http://ogp.me/ns#"{{ end }}>
<html lang="en-US">
<!DOCTYPE html>
<html lang="en-US" {{ if .OpenGraphItems }} prefix="og: http://ogp.me/ns#"{{ end }}>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">