From d4d6c760e59d86432074f7dd9be77400693506b3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:21:56 -0800 Subject: [PATCH] d2dagrelayout: Fix regexp See https://github.com/terrastruct/d2/pull/394#discussion_r1042504655 --- d2layouts/d2dagrelayout/layout.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index e1d29175e..ec72a91c6 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -261,7 +261,7 @@ func escapeID(id string) string { // fixes \\ id = strings.ReplaceAll(id, "\\", `\\`) // replaces \n with \\n whenever \n is not preceded by \ (does not replace \\n) - re := regexp.MustCompile(`[^\\](\n)`) + re := regexp.MustCompile(`[^\\]\n`) id = re.ReplaceAllString(id, `\\n`) // avoid an unescaped \r becoming a \n in the layout result id = strings.ReplaceAll(id, "\r", `\r`)