Skip to content

Commit

Permalink
🎨 Improve HTML code clipping siyuan-note/siyuan#11642
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Jun 4, 2024
1 parent 7b72f65 commit d725318
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion 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.

1 change: 1 addition & 0 deletions test/h2m_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

var html2MdTests = []parseTest{

{"128", "<figure class=\"code\"><div class=\"highlight\"><table><tbody><tr><td class=\"gutter\"><pre class=\"line-numbers\"><span class=\"line-number\">1</span>\n</pre></td><td class=\"code\"><pre><code class=\"\"><span class=\"line\">$ aria2c http://example.org/mylinux.iso</span></code></pre></td></tr></tbody></table></div></figure>", "```\n$ aria2c http://example.org/mylinux.iso\n```\n"},
{"127", "<table id=\"tablepress-85\" class=\"tablepress tablepress-id-85\">\n<tbody class=\"row-hover\">\n<tr class=\"row-1 odd\">\n<td class=\"column-1\">参数</td>\n<td class=\"column-2\">作用</td>\n</tr>\n<tr class=\"row-2 even\">\n<td class=\"column-1\">listen=[YES|NO]</td>\n<td class=\"column-2\">是否以独立运行的方式监听服务</td>\n</tr>\n</tbody>\n</table>", "| 参数 | 作用 |\n| ------------------ | ------------------------------ |\n| listen=[YES\\|NO] | 是否以独立运行的方式监听服务 |\n"},
{"126", "<div class=\"mwe-math-element\"><div class=\"mwe-math-mathml-display mwe-math-mathml-a11y\" style=\"display: none;\"><math display=\"block\" xmlns=\"http://www.w3.org/1998/Math/MathML\" alttext=\"{\\displaystyle \\{x\\,\\mid \\,f(x)>t\\}\\in X\\quad \\forall t\\in \\mathbb {R} .}\">\n <semantics>\n <mrow class=\"MJX-TeXAtom-ORD\">\n <mstyle displaystyle=\"true\" scriptlevel=\"0\">\n <mo fence=\"false\" stretchy=\"false\">{</mo>\n <mi>x</mi>\n <mspace width=\"thinmathspace\"></mspace>\n <mo>∣<!-- ∣ --></mo>\n <mspace width=\"thinmathspace\"></mspace>\n <mi>f</mi>\n <mo stretchy=\"false\">(</mo>\n <mi>x</mi>\n <mo stretchy=\"false\">)</mo>\n <mo>&gt;</mo>\n <mi>t</mi>\n <mo fence=\"false\" stretchy=\"false\">}</mo>\n <mo>∈<!-- ∈ --></mo>\n <mi>X</mi>\n <mspace width=\"1em\"></mspace>\n <mi mathvariant=\"normal\">∀<!-- ∀ --></mi>\n <mi>t</mi>\n <mo>∈<!-- ∈ --></mo>\n <mrow class=\"MJX-TeXAtom-ORD\">\n <mi mathvariant=\"double-struck\">R</mi>\n </mrow>\n <mo>.</mo>\n </mstyle>\n </mrow>\n <annotation encoding=\"application/x-tex\">{\\displaystyle \\{x\\,\\mid \\,f(x)&gt;t\\}\\in X\\quad \\forall t\\in \\mathbb {R} .}</annotation>\n </semantics>\n</math></div><img src=\"https://wikimedia.org/api/rest_v1/media/math/render/svg/f2121f534e667a154f49e6f5b9d2b5d10e08acd6\" class=\"mwe-math-fallback-image-display mw-invert skin-invert\" aria-hidden=\"true\" style=\"vertical-align: -0.838ex; width:29.163ex; height:2.843ex;\" alt=\"{\\displaystyle \\{x\\,\\mid \\,f(x)>t\\}\\in X\\quad \\forall t\\in \\mathbb {R} .}\"></div>", "$$\n{\\displaystyle \\{x\\,\\mid \\,f(x)>t\\}\\in X\\quad \\forall t\\in \\mathbb {R} .}\n$$\n"},
{"125", "<p><span class=\"katex\"><span class=\"katex-mathml\"><math xmlns=\"http://www.w3.org/1998/Math/MathML\"><semantics><mrow><mo>∫</mo><mfrac><mrow><mi>d</mi><mi>x</mi></mrow><msqrt><mrow><mi>a</mi><mo>+</mo><mi>b</mi><msup><mi>x</mi><mn>2</mn></msup></mrow></msqrt></mfrac></mrow><annotation encoding=\"application/x-tex\">\\int \\frac{dx}{\\sqrt{a + bx^2}}</annotation></semantics></math></span></span></p>", "$\\int \\frac{dx}{\\sqrt{a + bx^2}}$\n"},
Expand Down
4 changes: 4 additions & 0 deletions vditor_wysiwyg.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ func (lute *Lute) adjustTableCode(n *html.Node) {
}
}
}

for _, unlink := range unlinks {
unlink.Unlink()
}
}

for c := n.FirstChild; nil != c; c = c.NextSibling {
Expand Down

0 comments on commit d725318

Please sign in to comment.