From 845ddc5db6cf55b17a4fc67491a5b8c77f208853 Mon Sep 17 00:00:00 2001 From: Rob Farrow Date: Thu, 3 Jun 2021 12:31:37 -0700 Subject: [PATCH] quote name --- encoder.go | 5 ++++- tests/test0.brf | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/encoder.go b/encoder.go index 164098d..a246c26 100644 --- a/encoder.go +++ b/encoder.go @@ -53,7 +53,10 @@ func (node *Node) write(out *strings.Builder) []*Node { indent := strings.Repeat(" ", node.Indent) out.WriteString(indent + node.Type) if len(node.Name) > 0 { - out.WriteString(":" + node.Name) + if NoQuote(node.Name) { + out.WriteString(":" + node.Name) + } + out.WriteString(fmt.Sprintf(":%q", node.Name)) } for key, val := range node.Keys { if NoQuote(val) { diff --git a/tests/test0.brf b/tests/test0.brf index 5c2e233..e51ba4c 100644 --- a/tests/test0.brf +++ b/tests/test0.brf @@ -1,5 +1,5 @@ html - head + head:"go-flags" title `My Web Page` body class:mybody h1 `My Web Page`