Skip to content

Commit 676f637

Browse files
committed
use ReplaceAll and reuse escapePipe
1 parent e8750d8 commit 676f637

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

renderer/asciidoctor.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ func (adr *AsciidoctorRenderer) TemplateValue(key string) string {
151151
func (adr *AsciidoctorRenderer) RenderFieldDoc(text string) string {
152152
// Escape the pipe character, which has special meaning for asciidoc as a way to format tables,
153153
// so that including | in a comment does not result in wonky tables.
154-
out := strings.ReplaceAll(text, "|", "\\|")
154+
out := escapePipe(text)
155155

156156
// Trim any leading and trailing whitespace from each line.
157157
lines := strings.Split(out, "\n")
@@ -194,12 +194,12 @@ func escapeFirstAsterixInEachPair(text string) string {
194194
// escapePipe ensures sufficient escapes are added to pipe characters, so they are not mistaken
195195
// for asciidoctor table formatting.
196196
func escapePipe(text string) string {
197-
return strings.Replace(text, "|", "\\|", -1)
197+
return strings.ReplaceAll(text, "|", "\\|")
198198
}
199199

200200
// escapeCurlyBraces ensures sufficient escapes are added to curly braces, so they are not mistaken
201201
// for asciidoctor id attributes.
202202
func escapeCurlyBraces(text string) string {
203203
// Per asciidoctor docs, only the leading curly brace needs to be escaped.
204-
return strings.Replace(text, "{", "\\{", -1)
204+
return strings.ReplaceAll(text, "{", "\\{")
205205
}

0 commit comments

Comments
 (0)