mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-29 11:02:28 +08:00
feat(import/markdown): handle markup in note title
This commit is contained in:
parent
08a56300b0
commit
27ccc56b6d
@ -15,9 +15,10 @@
|
|||||||
## ✨ Improvements
|
## ✨ Improvements
|
||||||
|
|
||||||
* Add week note and quarter note support by @JYC333
|
* Add week note and quarter note support by @JYC333
|
||||||
* Markdown export:
|
* Markdown import/export:
|
||||||
* Reduce extra whitespace between list items.
|
* Reduce extra whitespace between list items.
|
||||||
* Preserve include note.
|
* Preserve include note.
|
||||||
|
* Handle note titles that contain inline code.
|
||||||
* In-app help:
|
* In-app help:
|
||||||
* Document structure is now precalculated, so start-up time should be slightly increased.
|
* Document structure is now precalculated, so start-up time should be slightly increased.
|
||||||
* Optimized the content in order to reduce the size on disk.
|
* Optimized the content in order to reduce the size on disk.
|
||||||
|
@ -44,11 +44,18 @@ describe("markdown", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("parses duplicate title with escape correctly", () => {
|
it("parses duplicate title with escape correctly", () => {
|
||||||
const result = markdownService.renderToHtml(trimIndentation`\
|
const titles = [
|
||||||
# What's new
|
"What's new",
|
||||||
Hi there
|
"Node.js, Electron and `better-sqlite3`"
|
||||||
`, "What's new")
|
];
|
||||||
expect(result).toBe(`<p>Hi there</p>`);
|
|
||||||
|
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", () => {
|
it("trims unnecessary whitespace", () => {
|
||||||
|
@ -8,6 +8,11 @@ import { parse, Renderer, type Tokens } from "marked";
|
|||||||
class CustomMarkdownRenderer extends Renderer {
|
class CustomMarkdownRenderer extends Renderer {
|
||||||
|
|
||||||
heading(data: Tokens.Heading): string {
|
heading(data: Tokens.Heading): string {
|
||||||
|
// Treat h1 as raw text.
|
||||||
|
if (data.depth === 1) {
|
||||||
|
return `<h1>${data.text}</h1>`;
|
||||||
|
}
|
||||||
|
|
||||||
return super.heading(data).trimEnd();
|
return super.heading(data).trimEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user