Skip to content

Commit

Permalink
Merge pull request #30 from amitaifrey/markdown-highlight
Browse files Browse the repository at this point in the history
syntax_sugar: add Highlight() function
  • Loading branch information
nao1215 authored Aug 29, 2024
2 parents c2cf2f8 + 2d6a591 commit e0055fa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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)
}
})
}

0 comments on commit e0055fa

Please sign in to comment.