mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 22:38:49 +01:00
🎨 支持聚焦导出 图片/PDF/HTML/Word https://github.com/siyuan-note/siyuan/issues/6607
导出时去掉内容块闪卡样式 https://github.com/siyuan-note/siyuan/issues/7374
This commit is contained in:
parent
23f83b3665
commit
3739177f97
1 changed files with 32 additions and 18 deletions
|
|
@ -366,15 +366,7 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||
return
|
||||
}
|
||||
|
||||
var tree *parse.Tree
|
||||
luteEngine := NewLute()
|
||||
tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
||||
if "d" != bt.Type {
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
tree = parse.Parse("", []byte(""), luteEngine.ParseOptions)
|
||||
tree.Root.FirstChild.InsertBefore(node)
|
||||
}
|
||||
tree.HPath = bt.HPath
|
||||
tree := prepareExportTree(bt)
|
||||
|
||||
if merge {
|
||||
var mergeErr error
|
||||
|
|
@ -449,6 +441,7 @@ func ExportMarkdownHTML(id, savePath string, docx, merge bool) (name, dom string
|
|||
}
|
||||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
luteEngine.SetFootnotes(true)
|
||||
md := treenode.FormatNode(tree.Root, luteEngine)
|
||||
tree = parse.Parse("", []byte(md), luteEngine.ParseOptions)
|
||||
|
|
@ -485,15 +478,7 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
return
|
||||
}
|
||||
|
||||
var tree *parse.Tree
|
||||
luteEngine := NewLute()
|
||||
tree, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
||||
if "d" != bt.Type {
|
||||
node := treenode.GetNodeInTree(tree, id)
|
||||
tree = parse.Parse("", []byte(""), luteEngine.ParseOptions)
|
||||
tree.Root.FirstChild.InsertBefore(node)
|
||||
}
|
||||
tree.HPath = bt.HPath
|
||||
tree := prepareExportTree(bt)
|
||||
|
||||
if merge {
|
||||
var mergeErr error
|
||||
|
|
@ -558,6 +543,7 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
}
|
||||
}
|
||||
|
||||
luteEngine := NewLute()
|
||||
if !pdf && "" != savePath { // 导出 HTML 需要复制静态资源
|
||||
srcs := []string{"stage/build/export", "stage/build/fonts", "stage/protyle"}
|
||||
for _, src := range srcs {
|
||||
|
|
@ -612,6 +598,29 @@ func ExportHTML(id, savePath string, pdf, image, keepFold, merge bool) (name, do
|
|||
return
|
||||
}
|
||||
|
||||
func prepareExportTree(bt *treenode.BlockTree) (ret *parse.Tree) {
|
||||
luteEngine := NewLute()
|
||||
ret, _ = filesys.LoadTree(bt.BoxID, bt.Path, luteEngine)
|
||||
if "d" != bt.Type {
|
||||
node := treenode.GetNodeInTree(ret, bt.ID)
|
||||
nodes := []*ast.Node{node}
|
||||
if "h" == bt.Type {
|
||||
children := treenode.HeadingChildren(node)
|
||||
for _, child := range children {
|
||||
nodes = append(nodes, child)
|
||||
}
|
||||
}
|
||||
|
||||
ret = parse.Parse("", []byte(""), luteEngine.ParseOptions)
|
||||
first := ret.Root.FirstChild
|
||||
for _, node := range nodes {
|
||||
first.InsertBefore(node)
|
||||
}
|
||||
}
|
||||
ret.HPath = bt.HPath
|
||||
return
|
||||
}
|
||||
|
||||
func processIFrame(tree *parse.Tree) {
|
||||
// 导出 PDF/Word 时 IFrame 块使用超链接 https://github.com/siyuan-note/siyuan/issues/4035
|
||||
var unlinks []*ast.Node
|
||||
|
|
@ -1501,6 +1510,11 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros, keepFold bool,
|
|||
}
|
||||
}
|
||||
|
||||
// 导出时去掉内容块闪卡样式 https://github.com/siyuan-note/siyuan/issues/7374
|
||||
if n.IsBlock() {
|
||||
n.RemoveIALAttr("custom-riff-decks")
|
||||
}
|
||||
|
||||
switch n.Type {
|
||||
case ast.NodeParagraph:
|
||||
if nil == n.FirstChild {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue