mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-24 02:20:13 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
94fe712efd
10 changed files with 40 additions and 27 deletions
6
app/stage/protyle/js/lute/lute.min.js
vendored
6
app/stage/protyle/js/lute/lute.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -190,7 +190,7 @@ func InstalledIcons() (ret []*Icon) {
|
|||
continue
|
||||
}
|
||||
|
||||
icon.PreferredReadme, _ = renderREADME(icon.URL, readme)
|
||||
icon.PreferredReadme, _ = renderLocalREADME("/appearance/icons/"+dirName+"/", readme)
|
||||
icon.Outdated = isOutdatedIcon(icon, bazaarIcons)
|
||||
ret = append(ret, icon)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ import (
|
|||
|
||||
type DisplayName struct {
|
||||
Default string `json:"default"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
DeDE string `json:"de_DE"`
|
||||
EnUS string `json:"en_US"`
|
||||
EsES string `json:"es_ES"`
|
||||
|
|
@ -58,7 +58,7 @@ type DisplayName struct {
|
|||
|
||||
type Description struct {
|
||||
Default string `json:"default"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
DeDE string `json:"de_DE"`
|
||||
EnUS string `json:"en_US"`
|
||||
EsES string `json:"es_ES"`
|
||||
|
|
@ -74,7 +74,7 @@ type Description struct {
|
|||
|
||||
type Readme struct {
|
||||
Default string `json:"default"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
ArSA string `json:"ar_SA"`
|
||||
DeDE string `json:"de_DE"`
|
||||
EnUS string `json:"en_US"`
|
||||
EsES string `json:"es_ES"`
|
||||
|
|
@ -172,7 +172,7 @@ func getPreferredReadme(readme *Readme) string {
|
|||
case "ar_SA":
|
||||
if "" != readme.ArSA {
|
||||
ret = readme.ArSA
|
||||
}
|
||||
}
|
||||
case "de_DE":
|
||||
if "" != readme.DeDE {
|
||||
ret = readme.DeDE
|
||||
|
|
@ -688,6 +688,17 @@ func renderREADME(repoURL string, mdData []byte) (ret string, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func renderLocalREADME(basePath string, mdData []byte) (ret string, err error) {
|
||||
luteEngine := lute.New()
|
||||
luteEngine.SetSoftBreak2HardBreak(false)
|
||||
luteEngine.SetCodeSyntaxHighlight(false)
|
||||
linkBase := basePath
|
||||
luteEngine.SetLinkBase(linkBase)
|
||||
ret = luteEngine.Md2HTML(string(mdData))
|
||||
ret = util.LinkTarget(ret, linkBase)
|
||||
return
|
||||
}
|
||||
|
||||
var (
|
||||
packageLocks = map[string]*sync.Mutex{}
|
||||
packageLocksLock = sync.Mutex{}
|
||||
|
|
|
|||
|
|
@ -227,7 +227,7 @@ func InstalledPlugins(frontend string, checkUpdate bool) (ret []*Plugin) {
|
|||
continue
|
||||
}
|
||||
|
||||
plugin.PreferredReadme, _ = renderREADME(plugin.URL, readme)
|
||||
plugin.PreferredReadme, _ = renderLocalREADME("/plugins/"+dirName+"/", readme)
|
||||
plugin.Outdated = isOutdatedPlugin(plugin, bazaarPlugins)
|
||||
plugin.Incompatible = isIncompatiblePlugin(plugin, frontend)
|
||||
ret = append(ret, plugin)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ func InstalledTemplates() (ret []*Template) {
|
|||
continue
|
||||
}
|
||||
|
||||
template.PreferredReadme, _ = renderREADME(template.URL, readme)
|
||||
template.PreferredReadme, _ = renderLocalREADME("/templates/"+dirName+"/", readme)
|
||||
template.Outdated = isOutdatedTemplate(template, bazaarTemplates)
|
||||
ret = append(ret, template)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ func InstalledThemes() (ret []*Theme) {
|
|||
continue
|
||||
}
|
||||
|
||||
theme.PreferredReadme, _ = renderREADME(theme.URL, readme)
|
||||
theme.PreferredReadme, _ = renderLocalREADME("/appearance/themes/"+dirName+"/", readme)
|
||||
theme.Outdated = isOutdatedTheme(theme, bazaarThemes)
|
||||
ret = append(ret, theme)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ func InstalledWidgets() (ret []*Widget) {
|
|||
continue
|
||||
}
|
||||
|
||||
widget.PreferredReadme, _ = renderREADME(widget.URL, readme)
|
||||
widget.PreferredReadme, _ = renderLocalREADME("/widgets/"+dirName+"/", readme)
|
||||
widget.Outdated = isOutdatedWidget(widget, bazaarWidgets)
|
||||
ret = append(ret, widget)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ require (
|
|||
github.com/88250/epub v0.0.0-20230830085737-c19055cd1f48
|
||||
github.com/88250/go-humanize v0.0.0-20240424102817-4f78fac47ea7
|
||||
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689
|
||||
github.com/88250/lute v1.7.7-0.20250331141803-d7124e598e86
|
||||
github.com/88250/lute v1.7.7-0.20250403053607-31b58724a8c7
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1
|
||||
github.com/ClarkThan/ahocorasick v0.0.0-20231011042242-30d1ef1347f4
|
||||
github.com/ConradIrwin/font v0.2.1
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950 h1:Pa5hMiBceT
|
|||
github.com/88250/go-sqlite3 v1.14.13-0.20231214121541-e7f54c482950/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689 h1:39y5g7vnFAIcXhTN3IXPk7h2xBhC4a9hBTykDhHJqRY=
|
||||
github.com/88250/gulu v1.2.3-0.20250227144607-7f4570b0d689/go.mod h1:c8uVw25vW2W4dhJ/j4iYsX5H1hc19spim266jO5x2hU=
|
||||
github.com/88250/lute v1.7.7-0.20250331141803-d7124e598e86 h1:M4Nkeg4dl6qUaXdxDpinDqKYGBWFAq/IqGrD3y/0wWk=
|
||||
github.com/88250/lute v1.7.7-0.20250331141803-d7124e598e86/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/lute v1.7.7-0.20250403053607-31b58724a8c7 h1:EzmUVWBZdJ2V3vm/HjsG2+JiXCL3OLorT+MIHPB1/FQ=
|
||||
github.com/88250/lute v1.7.7-0.20250403053607-31b58724a8c7/go.mod h1:WYyUw//5yVw9BJnoVjx7rI/3szsISxNZCYGOqTIrV0o=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01 h1:AcFe63RXjIh1XtX/dc4Es3U8bYKjlEkvavHd1nFBOHM=
|
||||
github.com/88250/pdfcpu v0.3.14-0.20241201033812-5a93b7586a01/go.mod h1:fVfOloBzs2+W2VJCCbq60XIxc3yJHAZ0Gahv1oO0gyI=
|
||||
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1 h1:48T899JQDwyyRu9yXHePYlPdHtpJfrJEUGBMH3SMBWY=
|
||||
|
|
|
|||
|
|
@ -719,7 +719,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "em")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "em")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -729,7 +729,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "strong")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "strong")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -739,7 +739,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "kbd")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "kbd")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
|
|
@ -748,7 +748,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "mark")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "mark")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -758,7 +758,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "s")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "s")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -768,7 +768,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "sub")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sub")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
|
|
@ -777,7 +777,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "sup")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "sup")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
|
|
@ -786,7 +786,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "tag")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "tag")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
}
|
||||
|
|
@ -795,7 +795,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "u")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "u")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -844,7 +844,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return ast.WalkContinue
|
||||
}
|
||||
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, replacement, r, "text")
|
||||
replaceNodeTextMarkTextContent(n, method, keyword, escapedKey, replacement, r, "text")
|
||||
if "" == n.TextMarkTextContent {
|
||||
unlinks = append(unlinks, n)
|
||||
mergeSamePreNext(n)
|
||||
|
|
@ -926,14 +926,16 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||
return
|
||||
}
|
||||
|
||||
func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword string, replacement string, r *regexp.Regexp, typ string) {
|
||||
func replaceNodeTextMarkTextContent(n *ast.Node, method int, keyword, escapedKey string, replacement string, r *regexp.Regexp, typ string) {
|
||||
if 0 == method {
|
||||
if "tag" == typ {
|
||||
keyword = strings.TrimPrefix(keyword, "#")
|
||||
keyword = strings.TrimSuffix(keyword, "#")
|
||||
}
|
||||
|
||||
if strings.Contains(n.TextMarkTextContent, keyword) {
|
||||
if strings.Contains(n.TextMarkTextContent, escapedKey) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, escapedKey, util.EscapeHTML(replacement))
|
||||
} else if strings.Contains(n.TextMarkTextContent, keyword) {
|
||||
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement)
|
||||
}
|
||||
} else if 3 == method {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue