aboutsummaryrefslogtreecommitdiff
path: root/internal/behavior/roomrefs.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-10-05 18:16:47 -0400
committerhistoria <[not public]>2026-10-05 18:16:47 -0400
commit9d8c43cd68c960b9a6b8f781684f763e204a4498 (patch)
treec9e2a02094a8700db29db2768a0d058ce259a4f4 /internal/behavior/roomrefs.go
parent7a15a5d70004b28bf2a710fa0f536af2446e5b17 (diff)
downloadthehouseoficarus-9d8c43cd68c960b9a6b8f781684f763e204a4498.tar.gz
fix: shared YAML encoder and journal directory, text cleanup
Diffstat (limited to 'internal/behavior/roomrefs.go')
-rw-r--r--internal/behavior/roomrefs.go16
1 files changed, 11 insertions, 5 deletions
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) {