diff --git a/builder/go.mod b/builder/go.mod index da72bea3..0bb0fb08 100644 --- a/builder/go.mod +++ b/builder/go.mod @@ -8,11 +8,13 @@ require ( github.com/dsoprea/go-jpeg-image-structure/v2 v2.0.0-20221012074422-4f3f7e934102 github.com/fsnotify/fsnotify v1.7.0 github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 + github.com/google/go-cmp v0.6.0 github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/tdewolff/minify/v2 v2.20.14 github.com/yuin/goldmark v1.6.0 github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc golang.org/x/image v0.15.0 + golang.org/x/net v0.20.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -27,7 +29,6 @@ require ( github.com/go-xmlfmt/xmlfmt v1.1.2 // indirect github.com/golang/geo v0.0.0-20230421003525-6adc56603217 // indirect github.com/tdewolff/parse/v2 v2.7.9 // indirect - golang.org/x/net v0.20.0 // indirect golang.org/x/sys v0.16.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/builder/go.sum b/builder/go.sum index aa112761..f4d1c974 100644 --- a/builder/go.sum +++ b/builder/go.sum @@ -62,6 +62,8 @@ github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFig github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/geo v0.0.0-20230421003525-6adc56603217 h1:HKlyj6in2JV6wVkmQ4XmG/EIm+SCYlPZ+V4GWit7Z+I= github.com/golang/geo v0.0.0-20230421003525-6adc56603217/go.mod h1:8wI0hitZ3a1IxZfeH3/5I97CI8i5cLGsYe7xNhQGs9U= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/builder/markdown.go b/builder/markdown.go index abb34507..3c104011 100644 --- a/builder/markdown.go +++ b/builder/markdown.go @@ -2,8 +2,8 @@ package main import ( "bytes" - "encoding/json" "fmt" + "html/template" "io" "net/url" "regexp" @@ -137,12 +137,7 @@ func (r *CodeRenderer) Render(w markdown.BufWriter, source []byte, node ast.Node return ast.WalkStop, err } - jsonCode, err := json.Marshal(plainCode) - if err != nil { - return ast.WalkStop, err - } - - _, err = fmt.Fprintf(w, `
`, jsonCode) + _, err = fmt.Fprintf(w, ``, template.HTMLEscapeString(plainCode)) if err != nil { return ast.WalkStop, err } @@ -159,8 +154,8 @@ func (r *CodeRenderer) Render(w markdown.BufWriter, source []byte, node ast.Node func (r *CodeRenderer) WriteCodeBlockAssets(w io.Writer) error { _, err := fmt.Fprintf(w, ` `, + ` `, + ` `, + ` `, + `Hoisting
`, + `Hoisting for HTML!
`, + ` `, + `