This commit is contained in:
Liang Ding 2022-09-20 11:26:53 +08:00
parent 64bea9c004
commit aaedbb2a7f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 26 additions and 4 deletions

View file

@ -1096,6 +1096,12 @@ func exportTree(tree *parse.Tree, wysiwyg, expandKaTexMacros bool) (ret *parse.T
status := processFileAnnotationRef(refID, n) status := processFileAnnotationRef(refID, n)
unlinks = append(unlinks, n) unlinks = append(unlinks, n)
return status return status
} else if n.IsTextMarkType("tag") {
if !wysiwyg {
n.Type = ast.NodeText
n.Tokens = []byte(Conf.Export.TagOpenMarker + n.TextMarkTextContent + Conf.Export.TagCloseMarker)
return ast.WalkContinue
}
} }
case ast.NodeFileAnnotationRef: case ast.NodeFileAnnotationRef:
refIDNode := n.ChildByType(ast.NodeFileAnnotationRefID) refIDNode := n.ChildByType(ast.NodeFileAnnotationRefID)

View file

@ -399,7 +399,7 @@ func query2Stmt(queryStr string) (ret string) {
if !entering { if !entering {
return ast.WalkContinue return ast.WalkContinue
} }
if ast.NodeTag == n.Type { if ast.NodeTag == n.Type || (n.IsTextMarkType("tag")) {
tags = append(tags, n.Text()) tags = append(tags, n.Text())
} }
return ast.WalkContinue return ast.WalkContinue

View file

@ -91,6 +91,14 @@ func RemoveTag(label string) (err error) {
} }
} }
} }
nodeTags = node.ChildrenByType(ast.NodeTextMark)
for _, nodeTag := range nodeTags {
if nodeTag.IsTextMarkType("tag") {
if label == nodeTag.TextMarkTextContent {
unlinks = append(unlinks, nodeTag)
}
}
}
} }
for _, n := range unlinks { for _, n := range unlinks {
n.Unlink() n.Unlink()
@ -181,6 +189,14 @@ func RenameTag(oldLabel, newLabel string) (err error) {
} }
} }
} }
nodeTags = node.ChildrenByType(ast.NodeTextMark)
for _, nodeTag := range nodeTags {
if nodeTag.IsTextMarkType("tag") {
if oldLabel == nodeTag.TextMarkTextContent {
nodeTag.TextMarkTextContent = strings.ReplaceAll(nodeTag.TextMarkTextContent, oldLabel, newLabel)
}
}
}
} }
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), tree.Root.IALAttr("title"))) util.PushEndlessProgress(fmt.Sprintf(Conf.Language(111), tree.Root.IALAttr("title")))
if err = writeJSONQueue(tree); nil != err { if err = writeJSONQueue(tree); nil != err {

View file

@ -820,7 +820,7 @@ func tagFromNode(node *ast.Node) (ret string) {
return ast.WalkContinue return ast.WalkContinue
} }
if ast.NodeTag == n.Type { if ast.NodeTag == n.Type || n.IsTextMarkType("tag") {
tagBuilder.WriteString("#") tagBuilder.WriteString("#")
tagBuilder.WriteString(n.Text()) tagBuilder.WriteString(n.Text())
tagBuilder.WriteString("# ") tagBuilder.WriteString("# ")

View file

@ -81,7 +81,7 @@ func SelectSpansRawStmt(stmt string, limit int) (ret []*Span) {
} }
func QueryTagSpansByKeyword(keyword string, limit int) (ret []*Span) { func QueryTagSpansByKeyword(keyword string, limit int) (ret []*Span) {
stmt := "SELECT * FROM spans WHERE type = 'tag' AND content LIKE '%" + keyword + "%'" stmt := "SELECT * FROM spans WHERE type LIKE '%tag%' AND content LIKE '%" + keyword + "%'"
stmt += " LIMIT " + strconv.Itoa(limit) stmt += " LIMIT " + strconv.Itoa(limit)
rows, err := query(stmt) rows, err := query(stmt)
if nil != err { if nil != err {
@ -97,7 +97,7 @@ func QueryTagSpansByKeyword(keyword string, limit int) (ret []*Span) {
} }
func QueryTagSpans(p string, limit int) (ret []*Span) { func QueryTagSpans(p string, limit int) (ret []*Span) {
stmt := "SELECT * FROM spans WHERE type = 'tag'" stmt := "SELECT * FROM spans WHERE type LIKE '%tag%'"
if "" != p { if "" != p {
stmt += " AND path = '" + p + "'" stmt += " AND path = '" + p + "'"
} }