mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-11-14 14:51:53 +08:00
fix(import/markdown): title deduplication breaking special chars
This commit is contained in:
parent
3d10ac5e1f
commit
a2795f3440
@ -40,4 +40,12 @@ describe("markdown", () => {
|
||||
expect(result).toBe(trimIndentation`\
|
||||
<pre><code class="language-text-x-trilium-auto">Hi</code></pre>`);
|
||||
});
|
||||
|
||||
it("parses duplicate title with escape correctly", () => {
|
||||
const result = markdownService.renderToHtml(trimIndentation`\
|
||||
# What's new
|
||||
Hi there
|
||||
`, "What's new")
|
||||
expect(result).toBe(`\n<p>Hi there</p>\n`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
"use strict";
|
||||
|
||||
import { unescapeHtml } from "../utils.js";
|
||||
|
||||
function handleH1(content: string, title: string) {
|
||||
let isFirstH1Handled = false;
|
||||
|
||||
return content.replace(/<h1[^>]*>([^<]*)<\/h1>/gi, (match, text) => {
|
||||
text = unescapeHtml(text);
|
||||
const convertedContent = `<h2>${text}</h2>`;
|
||||
|
||||
// strip away very first found h1 tag, if it matches the title
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user