Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nikolaydubina/htmlyaml
🐹 render YAML as HTML in Go
https://github.com/nikolaydubina/htmlyaml
code-editor code-visualisation data-visualisation go golang rendering text-formatting yaml
Last synced: 4 months ago
JSON representation
🐹 render YAML as HTML in Go
- Host: GitHub
- URL: https://github.com/nikolaydubina/htmlyaml
- Owner: nikolaydubina
- License: mit
- Created: 2023-03-18T14:16:35.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-03-21T11:36:14.000Z (11 months ago)
- Last Synced: 2024-05-01T14:34:55.644Z (10 months ago)
- Topics: code-editor, code-visualisation, data-visualisation, go, golang, rendering, text-formatting, yaml
- Language: Go
- Homepage:
- Size: 1.02 MB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-go - htmlyaml - Rich rendering of YAML as HTML in Go (Text Processing / Markup Languages)
README
## 🐹 htmlyaml: rich rendering of YAML as HTML in Go
[![codecov](https://codecov.io/gh/nikolaydubina/htmlyaml/branch/master/graph/badge.svg?token=yXmNdIDn8O)](https://codecov.io/gh/nikolaydubina/htmlyaml)
[![Go Report Card](https://goreportcard.com/badge/github.com/nikolaydubina/htmlyaml)](https://goreportcard.com/report/github.com/nikolaydubina/htmlyaml)
[![Go Reference](https://pkg.go.dev/badge/github.com/nikolaydubina/htmlyaml.svg)](https://pkg.go.dev/github.com/nikolaydubina/htmlyaml)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)
[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/nikolaydubina/htmlyaml/badge)](https://securityscorecards.dev/viewer/?uri=github.com/nikolaydubina/htmlyaml)* pure Go
* no Javascript
* no dependencies
* no `reflect`
* no `fmt`
* no `text/template`, `html/template`
* 300 LOC
* customizable rendering
* JSON Path for elements access![](./doc/example-color.png)
```go
// YAML has to be any
var v any
yaml.Unmarshal(exampleYAML, &v)htmlPage := htmlyaml.DefaultPageMarshaler.Marshal(v)
``````go
// 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 `` + s + ``
}
if v > 10 {
return `` + s + ``
}
return `` + s + ``
}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