mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-28 18:42:28 +08:00
feat(markdown/import): remove space in admonition
This commit is contained in:
parent
40d233dccc
commit
3c93fdc202
@ -99,7 +99,7 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</li
|
|||||||
|
|
||||||
After`;
|
After`;
|
||||||
const expected = `<p>Before</p><aside class="admonition note"><p>This is a note.</p></aside><aside class="admonition tip"><p>This is a tip.</p></aside><aside class="admonition important"><p>This is a very important information.</p></aside><aside class="admonition caution"><p>This is a caution.</p></aside><aside class="admonition warning"><h2>Title goes here</h2><p>This is a warning.</p></aside><p>After</p>`;
|
const expected = `<p>Before</p><aside class="admonition note"><p>This is a note.</p></aside><aside class="admonition tip"><p>This is a tip.</p></aside><aside class="admonition important"><p>This is a very important information.</p></aside><aside class="admonition caution"><p>This is a caution.</p></aside><aside class="admonition warning"><h2>Title goes here</h2><p>This is a warning.</p></aside><p>After</p>`;
|
||||||
expect(markdownService.renderToHtml(input, "Title")).toBe(expected);
|
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -43,14 +43,14 @@ class CustomMarkdownRenderer extends Renderer {
|
|||||||
|
|
||||||
if (ADMONITION_TYPE_MAPPINGS[type]) {
|
if (ADMONITION_TYPE_MAPPINGS[type]) {
|
||||||
const bodyWithoutHeader = body
|
const bodyWithoutHeader = body
|
||||||
.replace(/^<p>\[\!([A-Z]+)\]/, "<p>")
|
.replace(/^<p>\[\!([A-Z]+)\]\s*/, "<p>")
|
||||||
.replace(/^<p><\/p>/, ""); // Having a heading will generate an empty paragraph that we need to remove.
|
.replace(/^<p><\/p>/, ""); // Having a heading will generate an empty paragraph that we need to remove.
|
||||||
|
|
||||||
return `<aside class="admonition ${type}">\n${bodyWithoutHeader}</aside>\n`;
|
return `<aside class="admonition ${type}">${bodyWithoutHeader.trim()}</aside>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<blockquote>\n${body}</blockquote>\n`;
|
return `<blockquote>${body}</blockquote>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user