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`