🎨 Creating a dailynote template supports doc attributes https://github.com/siyuan-note/siyuan/issues/10698
This commit is contained in:
parent
852ca6744a
commit
8be272bfc6
1 changed files with 10 additions and 0 deletions
|
@ -169,6 +169,16 @@ func DocSaveAsTemplate(id, name string, overwrite bool) (code int, err error) {
|
|||
luteEngine := NewLute()
|
||||
formatRenderer := render.NewFormatRenderer(tree, luteEngine.RenderOptions)
|
||||
md := formatRenderer.Render()
|
||||
|
||||
// 单独渲染根节点的 IAL
|
||||
if 0 < len(tree.Root.KramdownIAL) {
|
||||
// 把 docIAL 中的 id 调整到第一个
|
||||
tree.Root.RemoveIALAttr("id")
|
||||
tree.Root.KramdownIAL = append([][]string{{"id", tree.Root.ID}}, tree.Root.KramdownIAL...)
|
||||
md = append(md, []byte("\n")...)
|
||||
md = append(md, parse.IAL2Tokens(tree.Root.KramdownIAL)...)
|
||||
}
|
||||
|
||||
name = util.FilterFileName(name) + ".md"
|
||||
name = util.TruncateLenFileName(name)
|
||||
savePath := filepath.Join(util.DataDir, "templates", name)
|
||||
|
|
Loading…
Add table
Reference in a new issue