Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2023-11-14 23:18:26 +08:00
commit b5b1ec25c6
5 changed files with 25 additions and 3 deletions

View file

@ -35,6 +35,7 @@ Below are the detailed changes in this version.
* [Editor missing after close all tabs when has pin tabs](https://github.com/siyuan-note/siyuan/issues/9624) * [Editor missing after close all tabs when has pin tabs](https://github.com/siyuan-note/siyuan/issues/9624)
* [Data synchronization accidentally deletes local files](https://github.com/siyuan-note/siyuan/issues/9631) * [Data synchronization accidentally deletes local files](https://github.com/siyuan-note/siyuan/issues/9631)
* [The window title is hidden after the graph is minimized](https://github.com/siyuan-note/siyuan/issues/9638) * [The window title is hidden after the graph is minimized](https://github.com/siyuan-note/siyuan/issues/9638)
* [Code content in templates is not properly escaped](https://github.com/siyuan-note/siyuan/issues/9649)
### Document ### Document

View file

@ -35,6 +35,7 @@
* [存在固定頁籤時關閉所有頁籤導致編輯器異常](https://github.com/siyuan-note/siyuan/issues/9624) * [存在固定頁籤時關閉所有頁籤導致編輯器異常](https://github.com/siyuan-note/siyuan/issues/9624)
* [資料同步誤刪本機檔案](https://github.com/siyuan-note/siyuan/issues/9631) * [資料同步誤刪本機檔案](https://github.com/siyuan-note/siyuan/issues/9631)
* [關係圖最小化後視窗標題被隱藏](https://github.com/siyuan-note/siyuan/issues/9638) * [關係圖最小化後視窗標題被隱藏](https://github.com/siyuan-note/siyuan/issues/9638)
* [未正確轉義範本程式碼內容](https://github.com/siyuan-note/siyuan/issues/9649)
### 改進文檔 ### 改進文檔

View file

@ -35,6 +35,7 @@
* [存在固定页签时关闭所有页签导致编辑器异常](https://github.com/siyuan-note/siyuan/issues/9624) * [存在固定页签时关闭所有页签导致编辑器异常](https://github.com/siyuan-note/siyuan/issues/9624)
* [数据同步误删本地文件](https://github.com/siyuan-note/siyuan/issues/9631) * [数据同步误删本地文件](https://github.com/siyuan-note/siyuan/issues/9631)
* [关系图最小化后窗口标题被隐藏](https://github.com/siyuan-note/siyuan/issues/9638) * [关系图最小化后窗口标题被隐藏](https://github.com/siyuan-note/siyuan/issues/9638)
* [未正确转义模板代码内容](https://github.com/siyuan-note/siyuan/issues/9649)
### 改进文档 ### 改进文档

View file

@ -74,7 +74,7 @@ func removeDuplicateDatabaseRefs() {
} }
if 0 < len(duplicatedRootIDs) { if 0 < len(duplicatedRootIDs) {
logging.LogWarnf("exist more than one ref duplicated [%d], reindex it", duplicatedRootIDs) logging.LogWarnf("exist more than one ref duplicated [%d], reindex it", len(duplicatedRootIDs))
} }
} }

View file

@ -20,7 +20,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/siyuan-note/siyuan/kernel/av"
"io/fs" "io/fs"
"os" "os"
"path/filepath" "path/filepath"
@ -33,10 +32,11 @@ import (
"github.com/88250/lute/ast" "github.com/88250/lute/ast"
"github.com/88250/lute/parse" "github.com/88250/lute/parse"
"github.com/88250/lute/render" "github.com/88250/lute/render"
sprig "github.com/Masterminds/sprig/v3" "github.com/Masterminds/sprig/v3"
"github.com/araddon/dateparse" "github.com/araddon/dateparse"
"github.com/siyuan-note/filelock" "github.com/siyuan-note/filelock"
"github.com/siyuan-note/logging" "github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/search" "github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql" "github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/treenode" "github.com/siyuan-note/siyuan/kernel/treenode"
@ -147,6 +147,25 @@ func DocSaveAsTemplate(id, name string, overwrite bool) (code int, err error) {
tree := prepareExportTree(bt) tree := prepareExportTree(bt)
addBlockIALNodes(tree, true) addBlockIALNodes(tree, true)
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
// Code content in templates is not properly escaped https://github.com/siyuan-note/siyuan/issues/9649
switch n.Type {
case ast.NodeCodeBlockCode:
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("&quot;"), []byte("\""))
case ast.NodeCodeSpanContent:
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte("&quot;"), []byte("\""))
case ast.NodeTextMark:
if n.IsTextMarkType("code") {
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, "&quot;", "\"")
}
}
return ast.WalkContinue
})
luteEngine := NewLute() luteEngine := NewLute()
formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions) formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions)
md := formatRenderer.Render() md := formatRenderer.Render()