mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🐛 The hyperlink in the changelog fails to jump to the browser to open https://github.com/siyuan-note/siyuan/issues/8458
This commit is contained in:
parent
8c9d947ff2
commit
b24c06fbce
4 changed files with 45 additions and 35 deletions
|
|
@ -16,7 +16,13 @@
|
|||
|
||||
package util
|
||||
|
||||
import "github.com/88250/lute"
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/88250/lute"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/siyuan-note/logging"
|
||||
)
|
||||
|
||||
func NewLute() (ret *lute.Lute) {
|
||||
ret = lute.New()
|
||||
|
|
@ -62,3 +68,25 @@ func NewStdLute() (ret *lute.Lute) {
|
|||
ret.SetInlineMathAllowDigitAfterOpenMarker(true) // Formula parsing supports $ followed by numbers when importing Markdown https://github.com/siyuan-note/siyuan/issues/8362
|
||||
return
|
||||
}
|
||||
|
||||
func LinkTarget(htmlStr, linkBase string) (ret string) {
|
||||
doc, err := goquery.NewDocumentFromReader(strings.NewReader(htmlStr))
|
||||
if nil != err {
|
||||
logging.LogErrorf("parse HTML failed: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
doc.Find("a").Each(func(i int, selection *goquery.Selection) {
|
||||
if href, ok := selection.Attr("href"); ok {
|
||||
if IsRelativePath(href) {
|
||||
selection.SetAttr("href", linkBase+href)
|
||||
}
|
||||
|
||||
// The hyperlink in the marketplace package README fails to jump to the browser to open https://github.com/siyuan-note/siyuan/issues/8452
|
||||
selection.SetAttr("target", "_blank")
|
||||
}
|
||||
})
|
||||
|
||||
ret, _ = doc.Find("body").Html()
|
||||
return
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue