Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/carsonslovoka/goldmark-emoji
An extension for the Goldmark
https://github.com/carsonslovoka/goldmark-emoji
chinese emoji goldmark goldmark-extension markdown taiwan tutorial
Last synced: 6 days ago
JSON representation
An extension for the Goldmark
- Host: GitHub
- URL: https://github.com/carsonslovoka/goldmark-emoji
- Owner: CarsonSlovoka
- License: mit
- Created: 2022-09-15T11:05:17.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-10-03T03:58:42.000Z (about 2 years ago)
- Last Synced: 2024-06-21T11:11:08.135Z (5 months ago)
- Topics: chinese, emoji, goldmark, goldmark-extension, markdown, taiwan, tutorial
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# goldmark-emoji
這是一個[goldmark](https://github.com/yuin/goldmark)的擴充功能
解析的對象為 `:joy:` 等類似範本
## USAGE
更多範例請參考[ExampleNewEmojiExtender](./v2/main_test.go)的代碼
```go
package mainimport (
"bytes"
"fmt"
emoji "github.com/CarsonSlovoka/goldmark-emoji/v2"
"github.com/CarsonSlovoka/goldmark-emoji/v2/def"
"github.com/yuin/goldmark"
"os"
)func Example() {
markdown := goldmark.New(
goldmark.WithExtensions(
emoji.NewEmojiExtender(
// def.Github(), def.TW(), ... // 可以不給,預設會用Github來當作標準, 您可以再加入喜歡的表情符號清單,如果找不到滿意的也可以自己建立
),
),
)markdown.Convert([]byte(":blush:"), os.Stdout)
// Output:
//😊
}
```### 自建立表情清單
如果要自建立表情符號清單餵入,可以參考def資料夾的{[github-emoji.go](v2/def/github-emoji.go), [ch-tw.go](v2/def/ch-tw.go)}
```go
func MyEmoji() Emojis {
return NewEmojis(
NewEmoji("desc ...", []rune{0x1F97A}, "QQ", "Pleading Face", ""), // 🥺
// ...
// NewEmoji("desc ...", []rune{}, ""),
)
}markdown := goldmark.New(
goldmark.WithExtensions(
emoji.NewEmojiExtender(
def.Github(), MyEmoji()
),
),
)markdown.Convert([]byte(":QQ:"), os.Stdout)
```## 參考資料
- [github.com/yuin/goldmark-emoji](https://github.com/yuin/goldmark-emoji#goldmark-emoji)
- [emojipedia.org](https://emojipedia.org/man-red-hair/)