mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
feat(import/markdown): preserve trailing semicolon in img
This commit is contained in:
parent
64ccea5702
commit
8cb10764b6
@ -165,7 +165,7 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</li
|
|||||||
|
|
||||||
it("preserves figures", () => {
|
it("preserves figures", () => {
|
||||||
const input = `<figure class="image"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
const input = `<figure class="image"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||||
const expected = /*html*/`<figure class="image"><img style="aspect-ratio:991/403" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
const expected = /*html*/`<figure class="image"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||||
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -99,6 +99,9 @@ function renderToHtml(content: string, title: string) {
|
|||||||
html = importUtils.handleH1(html, title);
|
html = importUtils.handleH1(html, title);
|
||||||
html = htmlSanitizer.sanitize(html);
|
html = htmlSanitizer.sanitize(html);
|
||||||
|
|
||||||
|
// Add a trailing semicolon to CSS styles.
|
||||||
|
html = html.replaceAll(/(<img style=".*?)"/g, "$1;\"");
|
||||||
|
|
||||||
// Remove slash for self-closing tags to match CKEditor's approach.
|
// Remove slash for self-closing tags to match CKEditor's approach.
|
||||||
html = html.replace(/<(\w+)([^>]*)\s+\/>/g, "<$1$2>");
|
html = html.replace(/<(\w+)([^>]*)\s+\/>/g, "<$1$2>");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user