🎨 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()
|
||||
md := luteEngine.HTML2Md(dom)
|
||||
md, _ := model.HTML2Markdown(dom)
|
||||
md = strings.TrimSpace(md)
|
||||
|
||||
var unlinks []*ast.Node
|
||||
|
|
|
@ -33,6 +33,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"runtime/debug"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
@ -927,8 +928,11 @@ func processBase64Img(n *ast.Node, dest string, assetDirPath string, err error)
|
|||
os.MkdirAll(base64TmpDir, 0755)
|
||||
|
||||
sep := strings.Index(dest, ";base64,")
|
||||
str := strings.TrimSpace(dest[sep+8:])
|
||||
re := regexp.MustCompile(`(?i)%0A`)
|
||||
str = re.ReplaceAllString(str, "\n")
|
||||
var decodeErr error
|
||||
unbased, decodeErr := base64.StdEncoding.DecodeString(dest[sep+8:])
|
||||
unbased, decodeErr := base64.StdEncoding.DecodeString(str)
|
||||
if nil != decodeErr {
|
||||
logging.LogErrorf("decode base64 image failed: %s", decodeErr)
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue