htmlyaml
CategoryText Processing
SubcategoryMarkup Languages
Stars0
Rich rendering of YAML as HTML in Go
About htmlyaml
🐹 htmlyaml: rich rendering of YAML as HTML in Go
- 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
Frequently Asked Questions
What is htmlyaml?
htmlyaml is a Text Processing library for the Go programming language. Rich rendering of YAML as HTML in Go
How do I install htmlyaml?
Install htmlyaml with the Go module system using `go get nikolaydubina/htmlyaml`. Check the repository for the current installation instructions.
What category does htmlyaml belong to?
htmlyaml is listed under Text Processing, specifically Markup Languages.