Skip to content

Commit

Permalink
🎨 Improve HTML math clipping siyuan-note/siyuan#12677
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Oct 14, 2024
1 parent c58c752 commit f6b9eba
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions ast/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ func (n *Node) Marker(entering bool) (ret string) {
if entering {
return "~"
}
case NodeInlineMathOpenMarker, NodeInlineMathCloseMarker:
if entering {
return "$"
}
case NodeKbdOpenMarker:
if entering {
return "<kbd>"
Expand Down
4 changes: 2 additions & 2 deletions javascript/lute.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion javascript/lute.min.js.map

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions parse/code_span.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package parse

import (
"bytes"

"github.com/88250/lute/ast"
"github.com/88250/lute/html"
"github.com/88250/lute/lex"
Expand Down Expand Up @@ -120,6 +121,8 @@ func (t *Tree) parseCodeSpan(block *ast.Node, ctx *InlineContext) (ret *ast.Node
content.Write(n.Tokens)
} else if ast.NodeHTMLEntity == n.Type {
content.Write(html.EscapeHTML(n.Tokens))
} else if ast.NodeInlineMathContent == n.Type {
content.Write(n.Tokens)
}
return ast.WalkContinue
})
Expand Down
1 change: 1 addition & 0 deletions test/m2p_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

var md2BlockDOMTests = []parseTest{

{"92", "`$ foo $`", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">\u200b<span data-type=\"code\">\u200b$ foo $</span>\u200b</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"91", "| foo |\n|---|\n| bar <br> baz |\n", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>foo</th></tr></thead><tbody><tr><td>bar <br /> baz</td></tr></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"90", "| foo |\n|---|\n| bar <br /> baz |\n", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>foo</th></tr></thead><tbody><tr><td>bar <br /> baz</td></tr></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"89", "| foo |\n|---|\n| bar <br/> baz |\n", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeTable\" class=\"table\" updated=\"20060102150405\"><div contenteditable=\"false\"><table contenteditable=\"true\" spellcheck=\"false\"><colgroup><col /></colgroup><thead><tr><th>foo</th></tr></thead><tbody><tr><td>bar <br /> baz</td></tr></tbody></table><div class=\"protyle-action__table\"><div class=\"table__resize\"></div><div class=\"table__select\"></div></div></div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
Expand Down

0 comments on commit f6b9eba

Please sign in to comment.