mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 19:12:27 +08:00
feat(import/markdown): preserve figure image size
This commit is contained in:
parent
7293f59a80
commit
64ccea5702
@ -149,7 +149,8 @@ function sanitize(dirtyHtml: string) {
|
||||
allowedTags,
|
||||
allowedAttributes: {
|
||||
"*": ["class", "style", "title", "src", "href", "hash", "disabled", "align", "alt", "center", "data-*"],
|
||||
input: ["type", "checked"]
|
||||
input: ["type", "checked"],
|
||||
img: ["width", "height"]
|
||||
},
|
||||
allowedStyles: {
|
||||
"*": {
|
||||
@ -161,6 +162,9 @@ function sanitize(dirtyHtml: string) {
|
||||
width: sizeRegex,
|
||||
height: sizeRegex
|
||||
},
|
||||
img: {
|
||||
"aspect-ratio": [ /^\d+\/\d+$/ ],
|
||||
},
|
||||
table: {
|
||||
"border-color": colorRegex,
|
||||
"border-style": [/^\s*(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\s*$/]
|
||||
|
@ -163,6 +163,12 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</li
|
||||
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
||||
});
|
||||
|
||||
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 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);
|
||||
});
|
||||
|
||||
it("converts inline math expressions into Mathtex format", () => {
|
||||
const input = `The equation is\u00a0$e=mc^{2}$.`;
|
||||
const expected = /*html*/`<p>The equation is <span class="math-tex">\\(e=mc^{2}\\)</span>.</p>`;
|
||||
|
Loading…
x
Reference in New Issue
Block a user