Skip to content

feat(export): add theme selection to PDF, HTML & Image exports and fix dark/light styling - #253

Merged
ThisIs-Developer merged 3 commits into
ThisIs-Developer:mainfrom
itznan:feat/export-theme-selection-and-styling-fixes
Sep 1, 2026
Merged

feat(export): add theme selection to PDF, HTML & Image exports and fix dark/light styling#253
ThisIs-Developer merged 3 commits into
ThisIs-Developer:mainfrom
itznan:feat/export-theme-selection-and-styling-fixes

Conversation

@itznan

@itznan itznan commented Aug 29, 2026

Copy link
Copy Markdown

Summary

This PR enhances export capabilities and fixes several styling and parsing edge cases across exports:

1. Theme Selection Dialogs for Exports

  • Export PDF: Added dedicated Light Theme and Dark Theme selectable options in the PDF export modal.
  • Export HTML: Added dedicated Light Theme and Dark Theme selectable options in the HTML export modal.
  • Export PNG: Added dedicated Light Theme and Dark Theme selectable options in the Image export modal.

2. Export & Preview Rendering Fixes

  • Dark Mode PDF Export:
    • Fixed white borders in raster PDF export by pre-filling page backgrounds in jsPDF and canvas render contexts with #0d1117.
    • Fixed vector PDF (window.print) @page margins and edge-to-edge dark background coverage.
    • Enhanced GitHub Alerts (> [!NOTE], > [!TIP], etc.) with dark backgrounds and color accents.
    • Replaced double-line bevel borders on --- horizontal dividers with clean dark styling.
  • Light Mode HTML Export:
    • Fixed tables appearing with dark backgrounds when viewed on dark-mode OS environments by explicitly setting data-color-mode="light" and overriding canvas variables.
    • Fixed Mermaid diagrams showing "Rendering Mermaid…" text in exported HTML by stripping loading status elements and properly initializing and invoking mermaid.run().
  • Frontmatter Parsing Hardening:
    • Prevented documents containing multiple --- dividers from incorrectly being treated as YAML frontmatter.

3. Desktop Offline Assets

  • Synchronized all changes to offline desktop resources via prepare.js.

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@ThisIs-Developer is attempting to deploy a commit to the BS Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
markdown-viwer Ready Ready Preview Aug 30, 2026 5:35pm

@itznan

itznan commented Aug 29, 2026

Copy link
Copy Markdown
Author

Hi @ThisIs-Developer,

Here is a summary of the updates and fixes implemented in this PR:

🎯 Key Changes & Enhancements

  1. Export Theme Selection Dialogs:

    • Added selectable Light / Dark theme options to the PDF, HTML, and Image (PNG/JPEG/WebP) export modals.
    • Users can now export in their preferred theme regardless of the current app viewing mode.
  2. Dark Mode PDF Export Overhaul:

    • Raster PDF (jsPDF + html2canvas): Fixed white border/margin seams by pre-filling page contexts with #0d1117 in jsPDF and setting canvas background color to #0d1117.
    • Browser Print (Vector PDF): Injected data-browser-print-export="dark" with dedicated @media print CSS rules covering code blocks (#161b22), tables, horizontal rules, syntax tokens (--color-prettylights-*), and GitHub Alerts ([!NOTE], [!TIP], [!WARNING], [!CAUTION], [!IMPORTANT]).
  3. Standalone HTML Export Improvements:

    • System Theme Isolation: Explicitly enforced data-color-mode and canvas variables so Light HTML exports do not inherit unwanted dark backgrounds from OS dark mode preferences.
    • Diagram Rendering: Removed loading placeholders (.diagram-status, .diagram-toolbar) and correctly initialized/executed mermaid.run() with the target theme so Mermaid diagrams render cleanly in exported HTML.
  4. Frontmatter Parsing Hardening:

    • Tightened regex checks in preview-worker.js and script.js to ensure horizontal rule dividers (---) later in the document do not trigger false YAML frontmatter blocks.
  5. Desktop Sync & E2E Test Coverage:

    • Synchronized all web updates to offline desktop assets via prepare.js.
    • Added automated E2E test coverage for export theme options in tests/e2e/export.spec.js.

The branch has also been rebased and synced with the latest main. Looking forward to your review!

This comment was marked as off-topic.

@ThisIs-Developer
ThisIs-Developer self-requested a review August 29, 2026 18:26

@ThisIs-Developer ThisIs-Developer left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @itznan, I really like the direction of this PR—especially the theme-aware export options and rendering improvements.

I have one UI suggestion:

  1. Please make the theme selector more compact and modern. Also, remember the last selected theme for each export type, so reopening the dialog restores the user’s previous selection instead of resetting it to the current application theme.
Image

Thank you for the work!

@itznan

itznan commented Aug 30, 2026

Copy link
Copy Markdown
Author

Hi @ThisIs-Developer,

I've addressed your UI feedback in commit a0a86c0:

  1. Compact & Modern Theme Selector:

    • Redesigned the theme selection across PDF, HTML, and Image export modals using a sleek 2-option segmented toggle (.export-theme-toggle) with light/dark icons.
    • Removed the bulky card layouts and descriptions to keep the dialogs compact, clean, and consistent with the app's design system.
  2. Persistent Theme Selection per Export Type:

    • Saved and restored user theme choices independently for PDF, HTML, and Image exports (\markdownViewerExportPdfTheme, \markdownViewerExportHtmlTheme, \markdownViewerExportPngTheme).
    • Reopening any export dialog now preserves the user's last selected export theme instead of resetting to the active app viewing theme.
    • Synchronized preferences with desktop Neutralino storage.
  3. Desktop Sync & Tests:

    • Synchronized all changes to offline desktop resources via \prepare.js.
    • Added automated E2E test coverage in \ ests/e2e/export.spec.js\ verifying the compact toggle layout and theme memory across dialog opens.

Ready for your review!

@ThisIs-Developer
ThisIs-Developer merged commit 8ccdaf7 into ThisIs-Developer:main Sep 1, 2026
4 checks passed
@ThisIs-Developer

Copy link
Copy Markdown
Owner

Thank you @itznan for implementing the requested changes.

The updated theme selector and remembered export preferences are a great addition and make the export experience much better.

Thank you again for the contribution and for improving Markdown Viewer!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants