feat(import/markdown): handle markup in note title

This commit is contained in:
Elian Doran 2025-04-12 12:46:00 +03:00
parent 08a56300b0
commit 27ccc56b6d
No known key found for this signature in database
3 changed files with 19 additions and 6 deletions

View File

@ -15,9 +15,10 @@
## ✨ Improvements
* Add week note and quarter note support by @JYC333
* Markdown export:
* Markdown import/export:
* Reduce extra whitespace between list items.
* Preserve include note.
* Handle note titles that contain inline code.
* In-app help:
* Document structure is now precalculated, so start-up time should be slightly increased.
* Optimized the content in order to reduce the size on disk.

View File

@ -44,11 +44,18 @@ describe("markdown", () => {
});
it("parses duplicate title with escape correctly", () => {
const result = markdownService.renderToHtml(trimIndentation`\
# What's new
Hi there
`, "What's new")
expect(result).toBe(`<p>Hi there</p>`);
const titles = [
"What's new",
"Node.js, Electron and `better-sqlite3`"
];
for (const title of titles) {
const result = markdownService.renderToHtml(trimIndentation`\
# ${title}
Hi there
`, title)
expect(result).toBe(`<p>Hi there</p>`);
}
});
it("trims unnecessary whitespace", () => {

View File

@ -8,6 +8,11 @@ import { parse, Renderer, type Tokens } from "marked";
class CustomMarkdownRenderer extends Renderer {
heading(data: Tokens.Heading): string {
// Treat h1 as raw text.
if (data.depth === 1) {
return `<h1>${data.text}</h1>`;
}
return super.heading(data).trimEnd();
}