mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-05 08:27:18 -04:00
Generate example styles from default styles
This commit is contained in:
committed by
Christian Muehlhaeuser
parent
6b9278b445
commit
bdbe6ae0c5
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/charmbracelet/glamour"
|
||||
"github.com/charmbracelet/glamour/ansi"
|
||||
)
|
||||
|
||||
func writeStyleJSON(filename string, styleConfig *ansi.StyleConfig) error {
|
||||
f, err := os.Create(filename)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
e := json.NewEncoder(f)
|
||||
e.SetIndent("", " ")
|
||||
return e.Encode(styleConfig)
|
||||
}
|
||||
|
||||
func run() error {
|
||||
for style, styleConfig := range glamour.DefaultStyles {
|
||||
if err := writeStyleJSON(filepath.Join("styles", style+".json"), styleConfig); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
if err := run(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user