This commit is contained in:
Liang Ding 2022-12-22 11:09:28 +08:00
parent 26e9c3a4c6
commit 28485f7ffb
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 46 additions and 0 deletions

View file

@ -17,6 +17,8 @@
package model
import (
"github.com/88250/lute"
"github.com/siyuan-note/siyuan/kernel/treenode"
"os"
"path/filepath"
"strings"
@ -31,6 +33,27 @@ import (
var Decks = map[string]*riff.Deck{}
var deckLock = sync.Mutex{}
func RenderFlashcard(blockID string) (content string, err error) {
tree, err := loadTreeByBlockID(blockID)
if nil != err {
return
}
node := treenode.GetNodeInTree(tree, blockID)
if nil == node {
return
}
luteEngine := NewLute()
luteEngine.RenderOptions.ProtyleContenteditable = false
if ast.NodeDocument == node.Type {
content = luteEngine.Tree2BlockDOM(tree, luteEngine.RenderOptions)
} else {
content = lute.RenderNodeBlockDOM(node, luteEngine.ParseOptions, luteEngine.RenderOptions)
}
return
}
func ReviewFlashcard(deckID string, blockID string, rating riff.Rating) (err error) {
deckLock.Lock()
deck := Decks[deckID]