package d2svgimport ()// Copied private functions from chroma. Their public functions do too much (write the whole SVG document)// https://github.com/alecthomas/chroma// >>> BEGINvar svgEscaper = strings.NewReplacer(`&`, "&",`<`, "<",`>`, ">",`"`, """,` `, " ",` `, "    ",)func styleToSVG( *chroma.Style) map[chroma.TokenType]string { := map[chroma.TokenType]string{}// NOTE this is in the original source code, but it just makes unhighlightable code turn into the bg color // Which I don't understand, and I get the results I want when I remove it. // bg := style.Get(chroma.Background)for := rangechroma.StandardTypes { := .Get()// if t != chroma.Background { // entry = entry.Sub(bg) // }if .IsZero() {continue } [] = svg.StyleEntryToSVG() }return}func styleAttr( map[chroma.TokenType]string, chroma.TokenType) string {if , := []; ! { = .SubCategory()if , := []; ! { = .Category()if , := []; ! {return"" } } }// Custom code := [] := []string{}ifstrings.Contains(, `font-weight="bold"`) { = strings.Replace(, `font-weight="bold"`, ``, 1) = append(, "text-mono-bold") }ifstrings.Contains(, `font-style="italic"`) { = strings.Replace(, `font-style="italic"`, ``, 1) = append(, "text-mono-italic") }iflen() > 0 { += `class="` + strings.Join(, " ") + `"` }returnstrings.TrimSpace()}// <<< END
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.