Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syntax_sugar: add Highlight() function #30

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions syntax_sugar.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ func BoldItalic(text string) string {
func Code(text string) string {
return fmt.Sprintf("`%s`", text)
}

// Highlight return text with highlight format.
// If you set text "Hello", it will be converted to "==Hello==".
func Highlight(text string) string {
return fmt.Sprintf("==%s==", text)
}
15 changes: 15 additions & 0 deletions syntax_sugar_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,18 @@ func TestCode(t *testing.T) {
}
})
}

func TestHighlight(t *testing.T) {
t.Parallel()

t.Run("success Highlight()", func(t *testing.T) {
t.Parallel()

want := "==Hello=="
got := Highlight("Hello")

if diff := cmp.Diff(want, got); diff != "" {
t.Errorf("value is mismatch (-want +got):\n%s", diff)
}
})
}
Loading