📚 htmlyaml - Awesome Go Library for Text Processing

Rich rendering of YAML as HTML in Go
🏷️ Text Processing
📂 Markup Languages
⭐ 0 stars
Detailed Description of htmlyaml
🐹 htmlyaml: rich rendering of YAML as HTML in Go
✨ Sponsored by NDX AI Shopping Assistant
- pure Go
- no Javascript
- no dependencies
- no
reflect - no
fmt - no
text/template,html/template - 300 LOC
- customizable rendering
- JSON Path for elements access

// YAML has to be any
var v any
yaml.Unmarshal(exampleYAML, &v)
htmlPage := htmlyaml.DefaultPageMarshaler.Marshal(v)
// YAML has to be any
var v any
yaml.Unmarshal(exampleYAML, &v)
// customize how to render HTML elements
s := htmlyaml.DefaultMarshaler
s.Number = func(k string, v float64, s string) string {
if k == "$.cakes.strawberry-cake.size" {
return `<div class="yaml-value yaml-number" style="color:red;">` + s + `</div>`
}
if v > 10 {
return `<div class="yaml-value yaml-number" style="color:blue;">` + s + `</div>`
}
return `<div class="yaml-value yaml-number">` + s + `</div>`
}
m := htmlyaml.DefaultPageMarshaler
m.Marshaler = &s
// write HTML page
htmlPage := m.Marshal(v)
Related Work
- https://github.com/alecthomas/chroma can render many languages into HTML with syntax highligting