mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-31 20:22:27 +08:00
feat(import/markdown): preserve image width
This commit is contained in:
parent
447439efd6
commit
b6c185fd32
@ -255,9 +255,10 @@ describe("Markdown export", () => {
|
|||||||
|
|
||||||
it("preserves image verbatim if it has a width or height attribute", () => {
|
it("preserves image verbatim if it has a width or height attribute", () => {
|
||||||
const scenarios = [
|
const scenarios = [
|
||||||
`<img src="Include Note_image.png" width="16" height="16">`,
|
/*html*/`<img src="Include Note_image.png" width="16" height="16">`,
|
||||||
`<img src="Include Note_image.png" width="16">`,
|
/*html*/`<img src="Include Note_image.png" width="16">`,
|
||||||
`<img src="Include Note_image.png" height="16">`
|
/*html*/`<img src="Include Note_image.png" height="16">`,
|
||||||
|
/*html*/`<img class="image_resized" style="aspect-ratio:853/315;width:50%;" src="6_File_image.png" width="853" height="315">`
|
||||||
];
|
];
|
||||||
for (const expected of scenarios) {
|
for (const expected of scenarios) {
|
||||||
const html = /*html*/`<p>${expected}</p>`;
|
const html = /*html*/`<p>${expected}</p>`;
|
||||||
|
@ -164,6 +164,8 @@ function sanitize(dirtyHtml: string) {
|
|||||||
},
|
},
|
||||||
img: {
|
img: {
|
||||||
"aspect-ratio": [ /^\d+\/\d+$/ ],
|
"aspect-ratio": [ /^\d+\/\d+$/ ],
|
||||||
|
width: sizeRegex,
|
||||||
|
height: sizeRegex
|
||||||
},
|
},
|
||||||
table: {
|
table: {
|
||||||
"border-color": colorRegex,
|
"border-color": colorRegex,
|
||||||
|
@ -163,10 +163,11 @@ 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", () => {
|
it("preserves figures and images with sizes", () => {
|
||||||
const scenarios = [
|
const scenarios = [
|
||||||
/*html*/`<figure class="image image-style-align-center image_resized" style="width:53.44%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`,
|
/*html*/`<figure class="image image-style-align-center image_resized" style="width:53.44%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`,
|
||||||
/*html*/`<figure class="image image-style-align-center image_resized" style="width:53.44%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`
|
/*html*/`<figure class="image image-style-align-center image_resized" style="width:53.44%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`,
|
||||||
|
/*html*/`<img class="image_resized" style="aspect-ratio:853/315;width:50%;" src="6_File_image.png" width="853" height="315">`
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const scenario of scenarios) {
|
for (const scenario of scenarios) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user