mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 22:11:04 +08:00
FIX: details fixes with extra formatting
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'details',
|
const BLOCK_TAGS = ['address', 'article', 'aside', 'audio', 'blockquote', 'canvas', 'dd', 'details',
|
||||||
'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
|
'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3',
|
||||||
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output',
|
'h4', 'h5', 'h6', 'header', 'hgroup', 'hr', 'iframe', 'noscript', 'ol', 'output',
|
||||||
'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video'];
|
'p', 'pre', 'section', 'table', 'tfoot', 'ul', 'video', 'summary'];
|
||||||
|
|
||||||
function splitAtLast(tag, block, next, first) {
|
function splitAtLast(tag, block, next, first) {
|
||||||
const endTag = `</${tag}>`;
|
const endTag = `</${tag}>`;
|
||||||
@ -34,7 +34,7 @@ export function setup(helper) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const m = /^<([^>]+)\>/.exec(block);
|
const m = /^\s*<\/?([^>]+)\>/.exec(block);
|
||||||
if (m && m[1]) {
|
if (m && m[1]) {
|
||||||
const tag = m[1].split(/\s/);
|
const tag = m[1].split(/\s/);
|
||||||
if (tag && tag[0] && BLOCK_TAGS.indexOf(tag[0]) !== -1) {
|
if (tag && tag[0] && BLOCK_TAGS.indexOf(tag[0]) !== -1) {
|
||||||
|
@ -57,11 +57,11 @@ test("pollOptionsCount", function() {
|
|||||||
const controller = this.subject();
|
const controller = this.subject();
|
||||||
controller.siteSettings = Discourse.SiteSettings;
|
controller.siteSettings = Discourse.SiteSettings;
|
||||||
|
|
||||||
controller.set("pollOptions", "1\n2\n")
|
controller.set("pollOptions", "1\n2\n");
|
||||||
|
|
||||||
equal(controller.get("pollOptionsCount"), 2, "it should equal 2");
|
equal(controller.get("pollOptionsCount"), 2, "it should equal 2");
|
||||||
|
|
||||||
controller.set("pollOptions", "")
|
controller.set("pollOptions", "");
|
||||||
|
|
||||||
equal(controller.get("pollOptionsCount"), 0, "it should equal 0");
|
equal(controller.get("pollOptionsCount"), 0, "it should equal 0");
|
||||||
});
|
});
|
||||||
|
@ -696,3 +696,13 @@ test("emoji - emojiSet", () => {
|
|||||||
{ emojiSet: 'twitter' },
|
{ emojiSet: 'twitter' },
|
||||||
`<p><img src="/images/emoji/twitter/smile.png?v=${v}" title=":smile:" class="emoji" alt=":smile:"></p>`);
|
`<p><img src="/images/emoji/twitter/smile.png?v=${v}" title=":smile:" class="emoji" alt=":smile:"></p>`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("details", () => {
|
||||||
|
cooked(`<details><summary>Info</summary>coucou</details>`,
|
||||||
|
`<details><summary>Info</summary>\n\n<p>coucou</p>\n\n</details>`,
|
||||||
|
"manual HTML for details");
|
||||||
|
cooked(` <details><summary>Info</summary>coucou</details>`,
|
||||||
|
`<details><summary>Info</summary>\n\n<p>coucou</p>\n\n</details>`,
|
||||||
|
"manual HTML for details with a space");
|
||||||
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user