diff --git a/public/parsing.wasm b/public/parsing.wasm index 7b47747..3138f32 100755 Binary files a/public/parsing.wasm and b/public/parsing.wasm differ diff --git a/src/parsing/bbcode.go b/src/parsing/bbcode.go index b3e9b1e..f63b1cb 100644 --- a/src/parsing/bbcode.go +++ b/src/parsing/bbcode.go @@ -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 diff --git a/src/parsing/parsing_test.go b/src/parsing/parsing_test.go index 08146f9..8377604 100644 --- a/src/parsing/parsing_test.go +++ b/src/parsing/parsing_test.go @@ -76,6 +76,11 @@ func main() { assert.Equal(t, 1, strings.Count(html, " - + +