mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
Support for table & ol tags for HTML pasting in composer
This commit is contained in:
@ -67,7 +67,7 @@ QUnit.test("converts heading tags", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts ul and ol list tags", assert => {
|
||||
QUnit.test("converts ul list tag", assert => {
|
||||
const html = `
|
||||
<ul>
|
||||
<li>Item 1</li>
|
||||
@ -95,7 +95,7 @@ QUnit.test("stripes unwanted inline tags", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts table as readable", assert => {
|
||||
QUnit.test("converts table tags", assert => {
|
||||
const html = `<address>Discourse Avenue</address><b>laboris</b>
|
||||
<table>
|
||||
<thead> <tr><th>Heading 1</th><th>Head 2</th></tr> </thead>
|
||||
@ -104,10 +104,21 @@ QUnit.test("converts table as readable", assert => {
|
||||
<tr><td><b>dolor</b></td> <td><i>sit amet</i></td></tr></tbody>
|
||||
</table>
|
||||
`;
|
||||
const markdown = `Discourse Avenue\n\n**laboris**\n\nHeading 1 Head 2\n\nLorem ipsum\n**dolor** _sit amet_`;
|
||||
const markdown = `Discourse Avenue\n\n**laboris**\n\n|Heading 1|Head 2|\n| --- | --- |\n|Lorem|ipsum|\n|**dolor**|_sit amet_|`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("returns empty string if table format not supported", assert => {
|
||||
const html = `<table>
|
||||
<thead> <tr><th>Headi\n\nng 1</th><th>Head 2</th></tr> </thead>
|
||||
<tbody>
|
||||
<tr><td>Lorem</td><td>ipsum</td></tr>
|
||||
<tr><td><a href="http://example.com"><img src="http://dolor.com/image.png" /></a></td> <td><i>sit amet</i></td></tr></tbody>
|
||||
</table>
|
||||
`;
|
||||
assert.equal(toMarkdown(html), "");
|
||||
});
|
||||
|
||||
QUnit.test("converts img tag", assert => {
|
||||
const url = "https://example.com/image.png";
|
||||
let html = `<img src="${url}" width="100" height="50">`;
|
||||
@ -184,3 +195,22 @@ QUnit.test("converts blockquote tag", assert => {
|
||||
output = "> Lorem ipsum\n> > dolor\n> > > sit\n> > amet";
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
||||
QUnit.test("converts ol list tag", assert => {
|
||||
const html = `Testing
|
||||
<ol>
|
||||
<li>Item 1</li>
|
||||
<li>
|
||||
Item 2
|
||||
<ol start="100">
|
||||
<li>Sub Item 1</li>
|
||||
<li>Sub Item 2</li>
|
||||
<ul><li>Sub <i>Sub</i> Item 1</li><li>Sub <b>Sub</b> Item 2</li></ul>
|
||||
</ol>
|
||||
</li>
|
||||
<li>Item 3</li>
|
||||
</ol>
|
||||
`;
|
||||
const markdown = `Testing\n\n1. Item 1\n2. Item 2\n\n 100. Sub Item 1\n 101. Sub Item 2\n\n * Sub _Sub_ Item 1\n * Sub **Sub** Item 2\n\n3. Item 3`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
Reference in New Issue
Block a user