diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 36ce88bba..9a9337585 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -1001,11 +1001,16 @@ func (c *compiler) validateKey(obj *d2graph.Object, f *d2ir.Field) { func (c *compiler) validateLabels(g *d2graph.Graph) { for _, obj := range g.Objects { - if obj.Shape.Value == d2target.ShapeText { - if strings.TrimSpace(obj.Label.Value) == "" { - c.errorf(obj.Label.MapKey, "text must have a label") - continue - } + if obj.Shape.Value != d2target.ShapeText { + continue + } + if obj.Attributes.Language != "" { + // blockstrings have already been validated + continue + } + if strings.TrimSpace(obj.Label.Value) == "" { + c.errorf(obj.Label.MapKey, "shape text must have a non-empty label") + continue } } } diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 3c33b03ce..98045e996 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -2720,7 +2720,6 @@ object: { b: " \n " { shape: text } - c: "" { shape: text } @@ -2728,6 +2727,10 @@ d: "" { shape: circle } e: " \n " +f: |md | +g: |md + +| `, expErr: ` `,