mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 10:02:59 +08:00
feat(import/markdown): handle markup in note title
This commit is contained in:
parent
08a56300b0
commit
27ccc56b6d
@ -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.
|
||||
|
@ -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", () => {
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user