render linked notes properly in pdf and docx

This commit is contained in:
Arjun 2026-03-13 21:24:01 +05:30
parent 26bf21d4da
commit 0a9697dda1

View file

@ -47,7 +47,14 @@ import { classifySchedule } from '@x/core/dist/knowledge/inline_tasks.js';
function markdownToHtml(markdown: string, title: string): string {
// Simple markdown to HTML conversion for export purposes
let html = markdown
// Escape HTML entities first (but preserve markdown syntax)
// Resolve wiki links [[Folder/Note Name]] or [[Folder/Note Name|Display]] to plain text
.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g, (_match, _path, display) => display.trim())
.replace(/\[\[([^\]]+)\]\]/g, (_match, linkPath: string) => {
// Use the last segment (filename) as the display name
const segments = linkPath.trim().split('/')
return segments[segments.length - 1]
})
// Escape HTML entities (but preserve markdown syntax)
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')