mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 15:19:01 +02:00
feat(import/markdown): preserve fractional widths
This commit is contained in:
parent
8977926c00
commit
447439efd6
@ -267,12 +267,12 @@ describe("Markdown export", () => {
|
||||
|
||||
it("preserves figures", () => {
|
||||
const html = /*html*/trimIndentation`\
|
||||
<figure class="image">
|
||||
<figure class="image" style="width:53.44%;">
|
||||
<img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991"
|
||||
height="403">
|
||||
</figure>
|
||||
`;
|
||||
const expected = `<figure class="image"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||
const expected = `<figure class="image" style="width:53.44%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||
expect(markdownExportService.toMarkdown(html)).toBe(expected);
|
||||
});
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
import TurndownService, { type Rule } from "turndown";
|
||||
import { gfm } from "../../../packages/turndown-plugin-gfm/src/gfm.js";
|
||||
import type { DOMElement } from "react";
|
||||
|
||||
let instance: TurndownService | null = null;
|
||||
|
||||
|
@ -142,7 +142,7 @@ function sanitize(dirtyHtml: string) {
|
||||
}
|
||||
|
||||
const colorRegex = [/^#(0x)?[0-9a-f]+$/i, /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/, /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/];
|
||||
const sizeRegex = [/^\d+(?:px|em|%)$/];
|
||||
const sizeRegex = [/^\d+\.?\d*(?:px|em|%)$/];
|
||||
|
||||
// to minimize document changes, compress H
|
||||
return sanitizeHtml(dirtyHtml, {
|
||||
|
@ -164,9 +164,14 @@ second line 2</code></pre><ul><li>Hello</li><li>world</li></ul><ol><li>Hello</li
|
||||
});
|
||||
|
||||
it("preserves figures", () => {
|
||||
const input = `<figure class="image image-style-align-center image_resized" style="width:50%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||
const expected = /*html*/`<figure class="image image-style-align-center image_resized" style="width:50%;"><img style="aspect-ratio:991/403;" src="Jump to Note_image.png" width="991" height="403"></figure>`;
|
||||
expect(markdownService.renderToHtml(input, "Title")).toStrictEqual(expected);
|
||||
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>`
|
||||
];
|
||||
|
||||
for (const scenario of scenarios) {
|
||||
expect(markdownService.renderToHtml(scenario, "Title")).toStrictEqual(scenario);
|
||||
}
|
||||
});
|
||||
|
||||
it("converts inline math expressions into Mathtex format", () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user