diff --git a/docs/Release Notes/Release Notes/v0.92.8-beta.md b/docs/Release Notes/Release Notes/v0.92.8-beta.md index b3f3158fe..791a1af62 100644 --- a/docs/Release Notes/Release Notes/v0.92.8-beta.md +++ b/docs/Release Notes/Release Notes/v0.92.8-beta.md @@ -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. diff --git a/src/services/import/markdown.spec.ts b/src/services/import/markdown.spec.ts index 429e61b67..02d0a81e8 100644 --- a/src/services/import/markdown.spec.ts +++ b/src/services/import/markdown.spec.ts @@ -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(`

Hi there

`); + 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(`

Hi there

`); + } }); it("trims unnecessary whitespace", () => { diff --git a/src/services/import/markdown.ts b/src/services/import/markdown.ts index e9554c2f5..d84deb043 100644 --- a/src/services/import/markdown.ts +++ b/src/services/import/markdown.ts @@ -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 `

${data.text}

`; + } + return super.heading(data).trimEnd(); }