mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-08-01 20:52: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,
|
allowedTags,
|
||||||
allowedAttributes: {
|
allowedAttributes: {
|
||||||
"*": ["class", "style", "title", "src", "href", "hash", "disabled", "align", "alt", "center", "data-*"],
|
"*": ["class", "style", "title", "src", "href", "hash", "disabled", "align", "alt", "center", "data-*"],
|
||||||
input: ["type", "checked"]
|
input: ["type", "checked"],
|
||||||
|
img: ["width", "height"]
|
||||||
},
|
},
|
||||||
allowedStyles: {
|
allowedStyles: {
|
||||||
"*": {
|
"*": {
|
||||||
@ -161,6 +162,9 @@ function sanitize(dirtyHtml: string) {
|
|||||||
width: sizeRegex,
|
width: sizeRegex,
|
||||||
height: sizeRegex
|
height: sizeRegex
|
||||||
},
|
},
|
||||||
|
img: {
|
||||||
|
"aspect-ratio": [ /^\d+\/\d+$/ ],
|
||||||
|
},
|
||||||
table: {
|
table: {
|
||||||
"border-color": colorRegex,
|
"border-color": colorRegex,
|
||||||
"border-style": [/^\s*(none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset)\s*$/]
|
"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);
|
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", () => {
|
it("converts inline math expressions into Mathtex format", () => {
|
||||||
const input = `The equation is\u00a0$e=mc^{2}$.`;
|
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>`;
|
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