mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-03 17:19:26 +08:00
🎨 Improve exporting HTML/Word
This commit is contained in:
parent
776b4fd6ee
commit
b5bfbbe14a
@ -65,6 +65,8 @@ func InitAppearance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Conf.Save()
|
Conf.Save()
|
||||||
|
|
||||||
|
util.InitEmojiChars()
|
||||||
}
|
}
|
||||||
|
|
||||||
func containTheme(name string, themes []*conf.AppearanceTheme) bool {
|
func containTheme(name string, themes []*conf.AppearanceTheme) bool {
|
||||||
|
@ -962,7 +962,7 @@ func MissingAssets() (ret []string) {
|
|||||||
|
|
||||||
func emojisInTree(tree *parse.Tree) (ret []string) {
|
func emojisInTree(tree *parse.Tree) (ret []string) {
|
||||||
if icon := tree.Root.IALAttr("icon"); "" != icon {
|
if icon := tree.Root.IALAttr("icon"); "" != icon {
|
||||||
if !strings.Contains(icon, "://") && !strings.HasPrefix(icon, "api/icon/") {
|
if !strings.Contains(icon, "://") && !strings.HasPrefix(icon, "api/icon/") && !util.NativeEmojiChars[icon] {
|
||||||
ret = append(ret, "/emojis/"+icon)
|
ret = append(ret, "/emojis/"+icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -752,7 +752,6 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||||||
to := filepath.Join(savePath, emoji)
|
to := filepath.Join(savePath, emoji)
|
||||||
if err := filelock.Copy(from, to); err != nil {
|
if err := filelock.Copy(from, to); err != nil {
|
||||||
logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, to, err)
|
logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, to, err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -910,7 +909,6 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||||||
to := filepath.Join(savePath, emoji)
|
to := filepath.Join(savePath, emoji)
|
||||||
if err := filelock.Copy(from, to); err != nil {
|
if err := filelock.Copy(from, to); err != nil {
|
||||||
logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, to, err)
|
logging.LogErrorf("copy emojis from [%s] to [%s] failed: %s", from, to, err)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,10 +17,13 @@
|
|||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
||||||
"github.com/88250/gulu"
|
"github.com/88250/gulu"
|
||||||
|
"github.com/siyuan-note/logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ContainsCJK(text string) bool {
|
func ContainsCJK(text string) bool {
|
||||||
@ -65,3 +68,29 @@ func RemoveInvalid(text string) (ret string) {
|
|||||||
ret = gulu.Str.RemovePUA(ret)
|
ret = gulu.Str.RemovePUA(ret)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var NativeEmojiChars = map[string]bool{}
|
||||||
|
|
||||||
|
func InitEmojiChars() {
|
||||||
|
builtConfPath := filepath.Join(AppearancePath, "emojis", "conf.json")
|
||||||
|
data, err := os.ReadFile(builtConfPath)
|
||||||
|
if err != nil {
|
||||||
|
logging.LogErrorf("read emojis conf.json failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var conf []map[string]interface{}
|
||||||
|
if err = gulu.JSON.UnmarshalJSON(data, &conf); err != nil {
|
||||||
|
logging.LogErrorf("unmarshal emojis conf.json failed: %s", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, emoji := range conf {
|
||||||
|
items := emoji["items"].([]interface{})
|
||||||
|
for _, item := range items {
|
||||||
|
e := item.(map[string]interface{})
|
||||||
|
NativeEmojiChars[e["unicode"].(string)] = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user