From 9d8c43cd68c960b9a6b8f781684f763e204a4498 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 18:16:47 -0400 Subject: fix: shared YAML encoder and journal directory, text cleanup --- internal/behavior/roomrefs.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'internal/behavior/roomrefs.go') diff --git a/internal/behavior/roomrefs.go b/internal/behavior/roomrefs.go index 4953092..c3604b7 100644 --- a/internal/behavior/roomrefs.go +++ b/internal/behavior/roomrefs.go @@ -132,14 +132,13 @@ func remapRoomRefList(list []any, idMap map[int]int) bool { return changed } -// MarshalYAMLMap encodes a decoded YAML map with the same settings the admin -// editor uses, so a rewritten content file matches what the editor would write -// and cannot drop a key a typed struct does not model. -func MarshalYAMLMap(m map[string]any) ([]byte, error) { +// MarshalYAML encodes a value as indented YAML (2-space), the same settings +// the admin editor and room-ref writers use. +func MarshalYAML(data any) ([]byte, error) { var buf bytes.Buffer enc := yaml.NewEncoder(&buf) enc.SetIndent(2) - if err := enc.Encode(m); err != nil { + if err := enc.Encode(data); err != nil { return nil, err } if err := enc.Close(); err != nil { @@ -148,6 +147,13 @@ func MarshalYAMLMap(m map[string]any) ([]byte, error) { return buf.Bytes(), nil } +// MarshalYAMLMap encodes a decoded YAML map with the same settings the admin +// editor uses, so a rewritten content file matches what the editor would write +// and cannot drop a key a typed struct does not model. +func MarshalYAMLMap(m map[string]any) ([]byte, error) { + return MarshalYAML(m) +} + // asInt coerces the numeric types a YAML decoder (or a JSON round-trip) can // produce for an integer field. func asInt(v any) (int, bool) { -- cgit v1.2.3