mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Support convert Base64 image when clipping HTML https://github.com/siyuan-note/siyuan/issues/11210
This commit is contained in:
parent
1f6f7c44d7
commit
04ba3ed011
2 changed files with 6 additions and 2 deletions
|
|
@ -122,7 +122,7 @@ func extensionCopy(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
luteEngine := util.NewStdLute()
|
luteEngine := util.NewStdLute()
|
||||||
md := luteEngine.HTML2Md(dom)
|
md, _ := model.HTML2Markdown(dom)
|
||||||
md = strings.TrimSpace(md)
|
md = strings.TrimSpace(md)
|
||||||
|
|
||||||
var unlinks []*ast.Node
|
var unlinks []*ast.Node
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -927,8 +928,11 @@ func processBase64Img(n *ast.Node, dest string, assetDirPath string, err error)
|
||||||
os.MkdirAll(base64TmpDir, 0755)
|
os.MkdirAll(base64TmpDir, 0755)
|
||||||
|
|
||||||
sep := strings.Index(dest, ";base64,")
|
sep := strings.Index(dest, ";base64,")
|
||||||
|
str := strings.TrimSpace(dest[sep+8:])
|
||||||
|
re := regexp.MustCompile(`(?i)%0A`)
|
||||||
|
str = re.ReplaceAllString(str, "\n")
|
||||||
var decodeErr error
|
var decodeErr error
|
||||||
unbased, decodeErr := base64.StdEncoding.DecodeString(dest[sep+8:])
|
unbased, decodeErr := base64.StdEncoding.DecodeString(str)
|
||||||
if nil != decodeErr {
|
if nil != decodeErr {
|
||||||
logging.LogErrorf("decode base64 image failed: %s", decodeErr)
|
logging.LogErrorf("decode base64 image failed: %s", decodeErr)
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue