fix(yaml): do not escape glyphs

resolves #1959
This commit is contained in:
Jan De Dobbeleer 2022-03-21 20:49:20 +01:00 committed by Jan De Dobbeleer
parent 289c32adbf
commit c1bdd735be
2 changed files with 5 additions and 8 deletions

View file

@ -15,7 +15,7 @@ import (
"github.com/gookit/config/v2"
"github.com/gookit/config/v2/json"
"github.com/gookit/config/v2/toml"
"github.com/gookit/config/v2/yaml"
yaml "github.com/gookit/config/v2/yamlv3"
"github.com/mitchellh/mapstructure"
)
@ -181,13 +181,11 @@ func (cfg *Config) Export(format string) string {
_, err := config.DumpTo(&result, cfg.format)
cfg.exitWithError(err)
var prefix string
switch cfg.format {
case YAML:
prefix = "# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
case TOML:
prefix = "#:schema https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
if cfg.format == YAML {
prefix := "# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
return prefix + result.String()
}
prefix := "#:schema https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json\n\n"
return prefix + escapeGlyphs(result.String())
}

View file

@ -60,7 +60,6 @@ require (
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
require (