Skip to content

Commit 0725e8d

Browse files
committed
🎨 Improve HTML clipping siyuan-note/siyuan#14460
1 parent 5483fba commit 0725e8d

File tree

6 files changed

+19
-4
lines changed

6 files changed

+19
-4
lines changed

javascript/lute.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

javascript/lute.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parse/blocks.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,11 @@ func (t *Tree) incorporateLine(line []byte) {
229229
// 数学公式块标记符没有换行的形式($$foo$$)需要判断右边结尾的闭合标记符
230230

231231
if 3 < len(container.Tokens) {
232-
tails := container.Tokens[bytes.LastIndex(container.Tokens, MathBlockMarker):]
232+
idx := bytes.LastIndex(container.Tokens, MathBlockMarker)
233+
if idx == -1 {
234+
break
235+
}
236+
tails := container.Tokens[idx:]
233237
if bytes.HasPrefix(tails, MathBlockMarker) && bytes.HasSuffix(tails, []byte("\n")) {
234238
if bytes.Equal(MathBlockMarker, bytes.TrimSpace(tails)) {
235239
t.Context.finalize(container)

test/h2m_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import (
1818

1919
var html2MdTests = []parseTest{
2020

21+
{"223", "<div class=\"language-math\" data-math=\"A = QR\"><span class=\"katex-display\"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\" style=\"height:0.6833em;\"></span><span class=\"mord mathnormal\">A</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span><span class=\"mrel\">=</span><span class=\"mspace\" style=\"margin-right:0.2778em;\"></span></span><span class=\"base\"><span class=\"strut\" style=\"height:0.8778em;vertical-align:-0.1944em;\"></span><span class=\"mord mathnormal\" style=\"margin-right:0.00773em;\">QR</span></span></span></span></span></div>", "$$\nA = QR\n$$\n"},
22+
{"222", "<span><span>&nbsp;</span></span><span class=\"language-math\" data-math=\" m \\times n \"><span class=\"katex\"><span class=\"katex-html\" aria-hidden=\"true\"><span class=\"base\"><span class=\"strut\"></span><span class=\"mord mathnormal\">m</span><span class=\"mspace\"></span><span class=\"mbin\">×</span><span class=\"mspace\"></span></span><span class=\"base\"><span class=\"strut\"></span><span class=\"mord mathnormal\">n</span></span></span></span></span><span><span>&nbsp;</span></span>", "$m \\times n$\n"},
2123
{"221", "<a href=\"https://github.com/Siunami/Latticework\">Latticework <span class=\"badge badge-notification clicks\" title=\"2 次点击\">2</span></a>", "[Latticework 2](https://github.com/Siunami/Latticework)\n"},
2224
{"220", "<p><strong>foo </strong>bar</p>", "**foo \u200b**bar\n"},
2325
{"219", "<ul><li>Via a distributed file system such as a<span>&nbsp;</span><a href=\"https://en.wikipedia.org/wiki/Network-attached_storage\">NAS server</a>,<span>&nbsp;</span><a href=\"https://en.wikipedia.org/wiki/Network_File_System\">NFS</a>,<span>&nbsp;</span><a href=\"https://en.wikipedia.org/wiki/File_Transfer_Protocol\">FTP</a>, or<span>&nbsp;</span><a href=\"https://linux.die.net/man/1/rsync\">rsync</a>;</li></ul>", "* Via a distributed file system such as a [NAS server](https://en.wikipedia.org/wiki/Network-attached_storage), [NFS](https://en.wikipedia.org/wiki/Network_File_System), [FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol), or [rsync](https://linux.die.net/man/1/rsync);\n"},

0 commit comments

Comments
 (0)