mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-22 01:20:12 +01:00
⚡ Improve block loading performance on Windows/Linux/macOS amd64 arch https://github.com/siyuan-note/siyuan/issues/9084
This commit is contained in:
parent
b0e9c2d2b9
commit
26d5832641
4 changed files with 93 additions and 18 deletions
|
|
@ -1,12 +1,18 @@
|
|||
// Lute - 一款结构化的 Markdown 引擎,支持 Go 和 JavaScript
|
||||
// Copyright (c) 2019-present, b3log.org
|
||||
// SiYuan - Refactor your thinking
|
||||
// Copyright (c) 2020-present, b3log.org
|
||||
//
|
||||
// Lute is licensed under Mulan PSL v2.
|
||||
// You can use this software according to the terms and conditions of the Mulan PSL v2.
|
||||
// You may obtain a copy of Mulan PSL v2 at:
|
||||
// http://license.coscl.org.cn/MulanPSL2
|
||||
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
// See the Mulan PSL v2 for more details.
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Affero General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU Affero General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
package filesys
|
||||
|
||||
|
|
@ -14,17 +20,16 @@ import (
|
|||
"bytes"
|
||||
"strings"
|
||||
|
||||
"github.com/88250/gulu"
|
||||
"github.com/88250/lute/ast"
|
||||
"github.com/88250/lute/editor"
|
||||
"github.com/88250/lute/parse"
|
||||
"github.com/88250/lute/util"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/siyuan-note/siyuan/kernel/treenode"
|
||||
)
|
||||
|
||||
func ParseJSONWithoutFix(jsonData []byte, options *parse.Options) (ret *parse.Tree, err error) {
|
||||
root := &ast.Node{}
|
||||
err = json.Unmarshal(jsonData, root)
|
||||
err = unmarshalJSON(jsonData, root)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
@ -45,7 +50,7 @@ func ParseJSONWithoutFix(jsonData []byte, options *parse.Options) (ret *parse.Tr
|
|||
|
||||
func ParseJSON(jsonData []byte, options *parse.Options) (ret *parse.Tree, needFix bool, err error) {
|
||||
root := &ast.Node{}
|
||||
err = json.Unmarshal(jsonData, root)
|
||||
err = unmarshalJSON(jsonData, root)
|
||||
if nil != err {
|
||||
return
|
||||
}
|
||||
|
|
@ -91,7 +96,7 @@ func ParseJSON(jsonData []byte, options *parse.Options) (ret *parse.Tree, needFi
|
|||
}
|
||||
|
||||
func genTreeByJSON(node *ast.Node, tree *parse.Tree, idMap *map[string]bool, needFix, needMigrate2Spec1 *bool, ignoreFix bool) {
|
||||
node.Tokens, node.Type = util.StrToBytes(node.Data), ast.Str2NodeType(node.TypeStr)
|
||||
node.Tokens, node.Type = gulu.Str.ToBytes(node.Data), ast.Str2NodeType(node.TypeStr)
|
||||
node.Data, node.TypeStr = "", ""
|
||||
node.KramdownIAL = parse.Map2IAL(node.Properties)
|
||||
node.Properties = nil
|
||||
|
|
@ -178,14 +183,14 @@ func fixLegacyData(tip, node *ast.Node, idMap *map[string]bool, needFix, needMig
|
|||
|
||||
switch node.Type {
|
||||
case ast.NodeIFrame:
|
||||
if bytes.Contains(node.Tokens, util.StrToBytes("iframe-content")) {
|
||||
start := bytes.Index(node.Tokens, util.StrToBytes("<iframe"))
|
||||
end := bytes.Index(node.Tokens, util.StrToBytes("</iframe>"))
|
||||
if bytes.Contains(node.Tokens, gulu.Str.ToBytes("iframe-content")) {
|
||||
start := bytes.Index(node.Tokens, gulu.Str.ToBytes("<iframe"))
|
||||
end := bytes.Index(node.Tokens, gulu.Str.ToBytes("</iframe>"))
|
||||
node.Tokens = node.Tokens[start : end+9]
|
||||
*needFix = true
|
||||
}
|
||||
case ast.NodeWidget:
|
||||
if bytes.Contains(node.Tokens, util.StrToBytes("http://127.0.0.1:6806")) {
|
||||
if bytes.Contains(node.Tokens, gulu.Str.ToBytes("http://127.0.0.1:6806")) {
|
||||
node.Tokens = bytes.ReplaceAll(node.Tokens, []byte("http://127.0.0.1:6806"), nil)
|
||||
*needFix = true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue