Skip to content

Commit 851644f

Browse files
committed
Fix alias emitted in mapping
The idea is to make sure that a YAML alias in a mapping is followed by a space before the : An issue appeared with the refactoring made recently that made sure to respect the YAML specification that allows having a `:` in an anchor and alias name.
1 parent dcff9c4 commit 851644f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

emitterc.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,16 @@ func (emitter *yamlEmitter) emitBlockMappingKey(event *yamlEvent, first bool) bo
813813
}
814814
if emitter.checkSimpleKey() {
815815
emitter.states = append(emitter.states, yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE)
816-
return emitter.emitNode(event, false, false, true, true)
816+
if !emitter.emitNode(event, false, false, true, true) {
817+
return false
818+
}
819+
820+
if event.typ == yaml_ALIAS_EVENT {
821+
// make sure there's a space after the alias
822+
return emitter.put(' ')
823+
}
824+
825+
return true
817826
}
818827
if !emitter.writeIndicator([]byte{'?'}, true, false, true) {
819828
return false

0 commit comments

Comments
 (0)