Skip to content

Commit

Permalink
🐛 设置 Emoji 接口需要加锁 siyuan-note/siyuan#3000
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Sep 28, 2021
1 parent 178d453 commit 29face6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lute.go
Expand Up @@ -14,6 +14,7 @@ package lute
import (
"bytes"
"strings"
"sync"

"github.com/88250/lute/ast"
"github.com/88250/lute/parse"
Expand Down Expand Up @@ -176,8 +177,13 @@ func (lute *Lute) GetEmojis() (ret map[string]string) {
return
}

var emojiLock = sync.Mutex{}

// PutEmojis 将指定的 emojiMap 合并覆盖已有的 Emoji 字典。
func (lute *Lute) PutEmojis(emojiMap map[string]string) {
emojiLock.Lock()
defer emojiLock.Unlock()

for k, v := range emojiMap {
lute.ParseOptions.AliasEmoji[k] = v
lute.ParseOptions.EmojiAlias[v] = k
Expand Down

0 comments on commit 29face6

Please sign in to comment.