mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: Keep supported HTML tags in HTML to Markdown conversion
This commit is contained in:
@ -128,3 +128,23 @@ QUnit.test("converts img tag", assert => {
|
||||
html = `<a><img src="${url}" alt="description" /></a>`;
|
||||
assert.equal(toMarkdown(html), ``);
|
||||
});
|
||||
|
||||
QUnit.test("suppring html tags by keeping them", assert => {
|
||||
let html = "Lorem <del>ipsum dolor</del> sit <big>amet, <ins>consectetur</ins></big>";
|
||||
let output = html;
|
||||
assert.equal(toMarkdown(html), output);
|
||||
|
||||
html = `Lorem <del style="font-weight: bold">ipsum dolor</del> sit <big>amet, <ins onclick="alert('hello')">consectetur</ins></big>`;
|
||||
assert.equal(toMarkdown(html), output);
|
||||
|
||||
html = `<a href="http://example.com" onload="">Lorem <del style="font-weight: bold">ipsum dolor</del> sit</a>.`;
|
||||
output = `[Lorem <del>ipsum dolor</del> sit](http://example.com).`;
|
||||
assert.equal(toMarkdown(html), output);
|
||||
|
||||
html = `Lorem <del>ipsum \n\n dolor</del> sit.`;
|
||||
assert.equal(toMarkdown(html), html);
|
||||
|
||||
html = `Lorem <a href="http://example.com"><del>ipsum \n\n\n dolor</del> sit.</a>`;
|
||||
output = `Lorem [<del>ipsum \n dolor</del> sit.](http://example.com)`;
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
Reference in New Issue
Block a user