Skip to content

Commit

Permalink
✅ Add testcases siyuan-note/siyuan#13240
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Nov 23, 2024
1 parent 974c97d commit d4196fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
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{

{"202", "<p>foo<u>bar</u><b><u>baz</u></b>bazz</p>", "foo<u>bar</u>**<u>baz</u>**bazz\n"},
{"201", "<figure data-size=\"normal\"><div><div class=\"GifPlayer css-1isopsn\" data-size=\"normal\" data-za-detail-view-path-module=\"GifItem\"><img class=\"ztext-gif\" width=\"480\" role=\"presentation\" src=\"https://pica.zhimg.com/v2-454df793026c3018d1f047d9bbf2aefe_b.jpg\" data-thumbnail=\"https://pica.zhimg.com/v2-454df793026c3018d1f047d9bbf2aefe_b.jpg\" data-size=\"normal\" alt=\"动图封面\" style=\"display: block;\"><div class=\"GifPlayer-icon css-d39tw7\"><svg width=\"50\" height=\"50\" viewBox=\"0 0 60 60\" xmlns=\"http://www.w3.org/2000/svg\"><g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\"><ellipse fill=\"#000\" opacity=\"0.45\" cx=\"30\" cy=\"30\" rx=\"30\" ry=\"30\"></ellipse><ellipse stroke=\"#FFF\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" opacity=\"0.5\" cx=\"30\" cy=\"30\" rx=\"26\" ry=\"26\"></ellipse></g><svg x=\"16\" y=\"18.5\"><g fill=\"#fff\"><path x=\"100\" y=\"100\" d=\"M12.8422852,12.9814453 L12.8422852,11.3994141 L7.63916016,11.3994141 L7.63916016,13.0517578 L10.9086914,13.0517578 L10.9086914,13.3242188 C10.8911133,15.2050781 9.46728516,16.4707031 7.39306641,16.4707031 C5.01123047,16.4707031 3.51708984,14.625 3.51708984,11.6367188 C3.51708984,8.70117188 5.00244141,6.84667969 7.34912109,6.84667969 C9.08056641,6.84667969 10.284668,7.68164062 10.7768555,9.2109375 L12.7543945,9.2109375 C12.3237305,6.64453125 10.2319336,5.00976562 7.34912109,5.00976562 C3.79833984,5.00976562 1.50439453,7.61132812 1.50439453,11.6542969 C1.50439453,15.75 3.77197266,18.3076172 7.36669922,18.3076172 C10.6889648,18.3076172 12.8422852,16.2246094 12.8422852,12.9814453 Z M17.5180664,18 L17.5180664,5.31738281 L15.5493164,5.31738281 L15.5493164,18 L17.5180664,18 Z M22.659668,18 L22.659668,12.7441406 L28.1088867,12.7441406 L28.1088867,11.0039062 L22.659668,11.0039062 L22.659668,7.11035156 L28.6098633,7.11035156 L28.6098633,5.31738281 L20.690918,5.31738281 L20.690918,18 L22.659668,18 Z\"></path></g></svg></svg></div></div></div></figure>", "![动图](https://pica.zhimg.com/v2-454df793026c3018d1f047d9bbf2aefe_b.webp)\n"},
{"200", "<section><span><strong><span>foo</span></strong></span></section>\n<section><span>bar</span></section>\n<section><span>baz</span></section>", "**foo**\n\nbar\n\nbaz\n"},
{"199", "<pre style=\"background-color: rgb(246, 248, 250);border-radius: 6px;padding: 4px;margin-bottom: 15px;overflow: auto;line-height: 1.45;color: rgb(68, 68, 68);font-size: 14px;letter-spacing: normal;text-align: start;border-width: initial !important;border-style: none !important;border-color: initial !important;\" class=\"js_darkmode__22\"><em style=\"cursor: pointer;font-size: 12px;color: rgb(51, 102, 153) !important;\"> 复制代码</em><em style=\"cursor: pointer;font-size: 12px;color: rgb(51, 102, 153) !important;\"> 隐藏代码<br></em><code style=\"font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, monospace;background: rgb(0, 0, 0);color: rgb(248, 248, 248);padding: 1em;display: block;overflow-x: auto;\" class=\"js_darkmode__23\">public <span style=\"color: rgb(255, 255, 182);\">Object</span> <span style=\"color: rgb(255, 255, 182);\">Index</span>(<span style=\"color: rgb(255, 255, 182);\">Object</span> functionObject, <span style=\"color: rgb(255, 255, 182);\">Object</span> newTarget, <span style=\"color: rgb(255, 255, 182);\">Index</span> <span style=\"color: rgb(198, 197, 254);\">this</span>, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg0, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg1, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg2, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg3, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg4, <span style=\"color: rgb(255, 255, 182);\">Object</span> arg5) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style=\"color: rgb(150, 203, 254);\">if</span> ((<span style=\"color: rgb(255, 115, 253);\">0</span> == arg3 ? <span style=\"color: rgb(255, 115, 253);\">1</span> : <span style=\"color: rgb(255, 115, 253);\">0</span>) != <span style=\"color: rgb(255, 115, 253);\">0</span>) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;arg3 = -<span style=\"color: rgb(255, 115, 253);\">1</span>;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style=\"color: rgb(150, 203, 254);\">if</span> ((<span style=\"color: rgb(255, 115, 253);\">0</span> == arg4 ? <span style=\"color: rgb(255, 115, 253);\">1</span> : <span style=\"color: rgb(255, 115, 253);\">0</span>) != <span style=\"color: rgb(255, 115, 253);\">0</span>) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;arg4 = <span style=\"color: rgb(198, 197, 254);\">null</span>;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style=\"color: rgb(255, 255, 182);\">Object</span> obj = <span style=\"color: rgb(198, 197, 254);\">super</span>(arg0, arg2, arg3, arg5);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style=\"color: rgb(150, 203, 254);\">if</span> ((<span style=\"color: rgb(168, 255, 96);\">\"function\"</span> == <span style=\"color: rgb(255, 255, 182);\">typeof</span>(arg4) ? <span style=\"color: rgb(255, 115, 253);\">1</span> : <span style=\"color: rgb(255, 115, 253);\">0</span>) != <span style=\"color: rgb(255, 115, 253);\">0</span>) {<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;obj.paramsGenerator_ = arg4;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;obj.__userInput = <span style=\"color: rgb(255, 255, 182);\">ObservedPropertySimplePU</span>(<span style=\"color: rgb(168, 255, 96);\">\"\"</span>, obj, <span style=\"color: rgb(168, 255, 96);\">\"userInput\"</span>);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;obj.secretKey = <span style=\"color: rgb(168, 255, 96);\">\"[f#fLw)??Pz?#9w)Du[ks[q[#w4D?4P4UJf,kU[f.rDkfwrDtq...)?J.#rP4[qrPDJkkJ|.9J|qffU?k|D4P4P[wkk.)k?JUJ[k#9kww[r??wUfw|PkrPUf.P#f.P#.PwJ4f4q.PU4UPDr9.[9fJ#PqP)cDDffJPDrJ.J4qPP[r[.JfJ4f|?U9#\"</span>;<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;obj.<span style=\"color: rgb(255, 255, 182);\">setInitiallyProvidedValue</span>(arg1);<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;obj.<span style=\"color: rgb(255, 255, 182);\">finalizeConstruction</span>();<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<span style=\"color: rgb(150, 203, 254);\">return</span> obj;<br>&nbsp; &nbsp; }</code></pre>", "```\npublic Object Index(Object functionObject, Object newTarget, Index this, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5) {\n if ((0 == arg3 ? 1 : 0) != 0) {\n arg3 = -1;\n }\n if ((0 == arg4 ? 1 : 0) != 0) {\n arg4 = null;\n }\n Object obj = super(arg0, arg2, arg3, arg5);\n if ((\"function\" == typeof(arg4) ? 1 : 0) != 0) {\n obj.paramsGenerator_ = arg4;\n }\n obj.__userInput = ObservedPropertySimplePU(\"\", obj, \"userInput\");\n obj.secretKey = \"[f#fLw)??Pz?#9w)Du[ks[q[#w4D?4P4UJf,kU[f.rDkfwrDtq...)?J.#rP4[qrPDJkkJ|.9J|qffU?k|D4P4P[wkk.)k?JUJ[k#9kww[r??wUfw|PkrPUf.P#f.P#.PwJ4f4q.PU4UPDr9.[9fJ#PqP)cDDffJPDrJ.J4qPP[r[.JfJ4f|?U9#\";\n obj.setInitiallyProvidedValue(arg1);\n obj.finalizeConstruction();\n return obj;\n }\n```\n"},
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{

{"94", "foo<u>bar</u>**<u>baz</u>**bazz\\n", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo<span data-type=\"u\">bar</span><span data-type=\"strong u\">baz</span>bazz\\n</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"93", "foo `` `bar` `` baz", "<div data-node-id=\"20060102150405-1a2b3c4\" data-node-index=\"1\" data-type=\"NodeParagraph\" class=\"p\" updated=\"20060102150405\"><div contenteditable=\"true\" spellcheck=\"false\">foo <span data-type=\"code\">\u200b`bar`</span>\u200b baz</div><div class=\"protyle-attr\" contenteditable=\"false\">\u200b</div></div>"},
{"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>"},
Expand Down

0 comments on commit d4196fd

Please sign in to comment.