diff --git a/README.md b/README.md
index 3bf17a7..c4f23e1 100644
--- a/README.md
+++ b/README.md
@@ -62,7 +62,7 @@ NoteDiscovery is a **lightweight, self-hosted note-taking application** that put
- 📱 **Responsive** - Works on desktop, tablet, and mobile
- 📂 **Simple Storage** - Plain markdown files in folders
- 🧮 **Math Support** - LaTeX/MathJax for beautiful equations
-- 📄 **HTML Export** - Share notes as standalone HTML files
+- 📄 **HTML Export & Print** - Export notes as standalone HTML or print
- 🕸️ **Graph View** - Interactive visualization of connected notes
- ⭐ **Favorites** - Star your most-used notes for instant access
- 📑 **Outline Panel** - Navigate headings with click-to-jump TOC
diff --git a/backend/export.py b/backend/export.py
index 1020bb3..0a0bd8f 100644
--- a/backend/export.py
+++ b/backend/export.py
@@ -300,18 +300,20 @@ def generate_export_html(
title: str,
content: str,
theme_css: str,
- is_dark: bool = False
+ is_dark: bool = False,
+ show_print_button: bool = False
) -> str:
"""
Generate a standalone HTML document for a note.
Uses marked.js for client-side markdown rendering.
-
+
Args:
title: The note title (for
and display)
content: Raw markdown content (images should already be base64 embedded)
theme_css: CSS content for theming
is_dark: Whether using a dark theme (for Mermaid/Highlight.js)
-
+ show_print_button: Whether to show a print button (for preview mode)
+
Returns:
Complete HTML document as string
"""
@@ -327,6 +329,24 @@ def generate_export_html(
highlight_theme = 'github-dark' if is_dark else 'github'
mermaid_theme = 'dark' if is_dark else 'default'
+ # Print toolbar HTML (only shown in preview mode)
+ print_toolbar_html = '''
+
+''' if show_print_button else ''
+
html = f'''
@@ -348,8 +368,8 @@ def generate_export_html(
-
-
-
-
-
-
-
-
-
-
-
-
- ${renderedHTML}
-
-
-`;
-
- // Create blob and download
- const blob = new Blob([htmlDocument], { type: 'text/html;charset=utf-8' });
- const url = URL.createObjectURL(blob);
+ // Download as blob
+ const blob = await response.blob();
+ const blobUrl = URL.createObjectURL(blob);
const a = document.createElement('a');
- a.href = url;
- a.download = `${noteName}.html`;
+ a.href = blobUrl;
+ a.download = filename;
document.body.appendChild(a);
a.click();
// Cleanup
- URL.revokeObjectURL(url);
+ URL.revokeObjectURL(blobUrl);
document.body.removeChild(a);
} catch (error) {
@@ -5308,6 +5114,22 @@ function noteApp() {
}
},
+ // Open print preview in new window
+ printPreview() {
+ if (!this.currentNote || !this.noteContent) {
+ alert(this.t('notes.no_content'));
+ return;
+ }
+
+ // Build API URL with current theme and download=false for inline display
+ const currentTheme = this.currentTheme || 'light';
+ const encodedPath = this.currentNote.split('/').map(s => encodeURIComponent(s)).join('/');
+ const url = `/api/export/${encodedPath}?theme=${encodeURIComponent(currentTheme)}&download=false`;
+
+ // Open in new window/tab
+ window.open(url, '_blank');
+ },
+
// Copy current note link to clipboard
async copyNoteLink() {
if (!this.currentNote) return;
diff --git a/frontend/index.html b/frontend/index.html
index 1fad5ea..a9ebe8d 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -70,8 +70,8 @@