Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Vanessa 2022-09-14 23:26:14 +08:00
commit b88d6e08ad
9 changed files with 36 additions and 16 deletions

View file

@ -25,13 +25,18 @@ export const unicode2Emoji = (unicode: string, assic = false) => {
if (unicode.indexOf(".") > -1) {
emoji = `<img src="/emojis/${unicode}"/>`;
} else if (isMobile() || window.siyuan.config.appearance.nativeEmoji || assic) {
unicode.split("-").forEach(item => {
if (item.length < 5) {
emoji += String.fromCodePoint(parseInt("0" + item, 16));
} else {
emoji += String.fromCodePoint(parseInt(item, 16));
}
});
try {
unicode.split("-").forEach(item => {
if (item.length < 5) {
emoji += String.fromCodePoint(parseInt("0" + item, 16));
} else {
emoji += String.fromCodePoint(parseInt(item, 16));
}
});
} catch (e) {
// 自定义表情搜索报错 https://github.com/siyuan-note/siyuan/issues/5883
// 这里忽略错误不做处理
}
} else {
emoji = `<svg class="custom-icon"><use xlink:href="#icon-${unicode}"></use></svg>`;
}

File diff suppressed because one or more lines are too long

View file

@ -7,7 +7,7 @@ require (
github.com/88250/css v0.1.2
github.com/88250/flock v0.8.2
github.com/88250/gulu v1.2.3-0.20220909041418-fdfa4d7380bf
github.com/88250/lute v1.7.5-0.20220914033628-cdff00d59d4b
github.com/88250/lute v1.7.5-0.20220914115349-63021a255914
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1
github.com/88250/pdfcpu v0.3.13
github.com/88250/vitess-sqlparser v0.0.0-20210205111146-56a2ded2aba1

View file

@ -19,8 +19,8 @@ github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5 h1:8HdZozCsXS
github.com/88250/go-sqlite3 v1.14.13-0.20220714142610-fbbda1ee84f5/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/88250/gulu v1.2.3-0.20220909041418-fdfa4d7380bf h1:q+iiBuKjdvUKj5dQQHCRs+g9oChTWkZmm7r1FMvtkfI=
github.com/88250/gulu v1.2.3-0.20220909041418-fdfa4d7380bf/go.mod h1:I1qBzsksFL2ciGSuqDE7R3XW4BUMrfDgOvSXEk7FsAI=
github.com/88250/lute v1.7.5-0.20220914033628-cdff00d59d4b h1:NlIeWlATxeeMFqsFBjH2TDuirEEhdjSpOOfhoRQbBQk=
github.com/88250/lute v1.7.5-0.20220914033628-cdff00d59d4b/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/lute v1.7.5-0.20220914115349-63021a255914 h1:ZayI/njXieIxM7IPNfPBpPowMpKm9u8QzRKMlgZUs6s=
github.com/88250/lute v1.7.5-0.20220914115349-63021a255914/go.mod h1:cEoBGi0zArPqAsp0MdG9SKinvH/xxZZWXU7sRx8vHSA=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1 h1:9Cb+iN639vUI2OcIBc+4oGwml9/0J6bL6dWNb8Al+1s=
github.com/88250/melody v0.0.0-20201115062536-c0b3394adcd1/go.mod h1:jH6MMPr8G7AMzaVmWHXZQiB1DKO3giWbcWZ7UoJ1teI=
github.com/88250/pdfcpu v0.3.13 h1:touMWMZkCGalMIbEg9bxYp7rETM+zwb9hXjwhqi4I7Q=

View file

@ -55,7 +55,7 @@ func renderOutline(node *ast.Node, luteEngine *lute.Lute) (ret string) {
tokens := html.EscapeHTML(n.Tokens)
tokens = bytes.ReplaceAll(tokens, []byte(" "), []byte("&nbsp;")) // 大纲面板条目中无法显示多个空格 https://github.com/siyuan-note/siyuan/issues/4370
buf.Write(tokens)
case ast.NodeInlineMath, ast.NodeStrong, ast.NodeEmphasis, ast.NodeCodeSpan:
case ast.NodeInlineMath, ast.NodeStrong, ast.NodeEmphasis, ast.NodeCodeSpan, ast.NodeTextMark, ast.NodeMark:
dom := lute.RenderNodeBlockDOM(n, luteEngine.ParseOptions, luteEngine.RenderOptions)
buf.WriteString(dom)
return ast.WalkSkipChildren

View file

@ -165,6 +165,10 @@ func FindReplace(keyword, replacement string, ids []string) (err error) {
if bytes.Contains(n.Tokens, []byte(keyword)) {
n.Tokens = bytes.ReplaceAll(n.Tokens, []byte(keyword), []byte(replacement))
}
case ast.NodeTextMark:
if strings.Contains(n.TextMarkTextContent, keyword) {
n.TextMarkTextContent = strings.ReplaceAll(n.TextMarkTextContent, keyword, replacement)
}
}
return ast.WalkContinue
})

View file

@ -654,6 +654,8 @@ func GetContainerText(container *ast.Node) string {
case ast.NodeText, ast.NodeLinkText, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
buf.Write(n.Tokens)
case ast.NodeTextMark:
buf.WriteString(n.Content())
case ast.NodeBlockRef:
if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
buf.WriteString(anchor.Text())

View file

@ -399,6 +399,8 @@ func resolveRefContent0(node *ast.Node, anchors *map[string]string, depth *int,
case ast.NodeText, ast.NodeLinkText, ast.NodeLinkTitle, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent:
buf.Write(n.Tokens)
case ast.NodeTextMark:
buf.WriteString(n.Content())
case ast.NodeBlockRef:
if anchor := n.ChildByType(ast.NodeBlockRefText); nil != anchor {
buf.WriteString(anchor.Text())
@ -537,7 +539,8 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
spans = append(spans, span)
walkStatus = ast.WalkContinue
return
case ast.NodeTag, ast.NodeInlineMath, ast.NodeCodeSpan, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline:
case ast.NodeTag, ast.NodeInlineMath, ast.NodeCodeSpan, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline, ast.NodeTextMark:
typ := treenode.TypeAbbr(n.Type.String())
var text string
switch n.Type {
case ast.NodeTag, ast.NodeEmphasis, ast.NodeStrong, ast.NodeStrikethrough, ast.NodeMark, ast.NodeSup, ast.NodeSub, ast.NodeKbd, ast.NodeUnderline:
@ -546,6 +549,9 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
text = n.ChildByType(ast.NodeInlineMathContent).TokensStr()
case ast.NodeCodeSpan:
text = n.ChildByType(ast.NodeCodeSpanContent).TokensStr()
case ast.NodeTextMark:
text = n.Content()
typ = typ + " " + n.TextMarkType
}
markdown := treenode.FormatNode(n, luteEngine)
@ -558,7 +564,7 @@ func buildSpanFromNode(n *ast.Node, tree *parse.Tree, rootID, boxID, p string) (
Path: p,
Content: text,
Markdown: markdown,
Type: treenode.TypeAbbr(n.Type.String()),
Type: typ,
IAL: treenode.IALStr(n),
}
spans = append(spans, span)
@ -1202,7 +1208,7 @@ func nSort(n *ast.Node) int {
case ast.NodeSuperBlock:
return 30
// 以下为行级元素
case ast.NodeText:
case ast.NodeText, ast.NodeTextMark:
return 200
case ast.NodeTag:
return 205

View file

@ -89,6 +89,8 @@ func NodeStaticContent(node *ast.Node) string {
case ast.NodeText, ast.NodeFileAnnotationRefText, ast.NodeFootnotesRef,
ast.NodeCodeSpanContent, ast.NodeInlineMathContent, ast.NodeCodeBlockCode, ast.NodeMathBlockContent, ast.NodeHTMLBlock:
buf.Write(n.Tokens)
case ast.NodeTextMark:
buf.WriteString(n.Content())
case ast.NodeBackslash:
buf.WriteByte(lex.ItemBackslash)
case ast.NodeBackslashContent:
@ -228,6 +230,7 @@ var typeAbbrMap = map[string]string{
"NodeSub": "sub",
"NodeKbd": "kbd",
"NodeUnderline": "underline",
"NodeTextMark": "textmark",
}
var abbrTypeMap = map[string]string{}