-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
syntax_sugar.go
53 lines (44 loc) · 1.6 KB
/
syntax_sugar.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package markdown
import "fmt"
// Link return text with link format.
// If you set text "Hello" and url "https://example.com",
// it will be converted to "[Hello](https://example.com)".
func Link(text, url string) string {
return fmt.Sprintf("[%s](%s)", text, url)
}
// Image return text with image format.
// If you set text "Hello" and url "https://example.com/image.png",
// it will be converted to "![Hello](https://example.com/image.png)".
func Image(text, url string) string {
return fmt.Sprintf("![%s](%s)", text, url)
}
// Strikethrough return text with strikethrough format.
// If you set text "Hello", it will be converted to "~~Hello~~".
func Strikethrough(text string) string {
return fmt.Sprintf("~~%s~~", text)
}
// Bold return text with bold format.
// If you set text "Hello", it will be converted to "**Hello**".
func Bold(text string) string {
return fmt.Sprintf("**%s**", text)
}
// Italic return text with italic format.
// If you set text "Hello", it will be converted to "*Hello*".
func Italic(text string) string {
return fmt.Sprintf("*%s*", text)
}
// BoldItalic return text with bold and italic format.
// If you set text "Hello", it will be converted to "***Hello***".
func BoldItalic(text string) string {
return fmt.Sprintf("***%s***", text)
}
// Code return text with code format.
// If you set text "Hello", it will be converted to "`Hello`".
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)
}