Skip to content

Commit

Permalink
✨ feat: add toComment
Browse files Browse the repository at this point in the history
  • Loading branch information
jingyuexing committed Feb 21, 2024
1 parent d0804d7 commit 4c695d4
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@ func getValidRef(refname string, symbol rune) string {
return strings.Join(word, "")
}

func toComment(val string, commentSymbol []string) string{
if len(commentSymbol) & 1 == 0 {
return strings.Join([]string{commentSymbol[0],val,commentSymbol[1]},"")
}
return commentSymbol[0] + val;
}

func deepReplace(target map[string]string, symbol rune, text string) string {
clone := strings.Clone(text)
list := strings.Split(clone, " ")
Expand All @@ -120,7 +127,7 @@ func deepReplace(target map[string]string, symbol rune, text string) string {
validRef := getValidRef(refName, rune(symbol))
refString, ok := target[validRef]
if !ok {
refString = "/*" + validRef + "*/"
refString = toComment(validRef,[]string{"/*","*/"})
}
values := deepReplace(target, symbol, refString)
clone = strings.Replace(clone, string(symbol)+refName, values, 1)
Expand Down

0 comments on commit 4c695d4

Please sign in to comment.