Feather MD v1.8.0
This is a minor feature update adding advanced document extensions (math rendering and interactive diagrams) alongside user interface polishing and keyboard layout adjustments.
Summary:
- Math Support: You can now write inline math (using
$E = mc^2$) and block math (using$$...$$) directly in your markdown documents, which render smoothly in the preview pane. - Mermaid Diagrams: Fenced code blocks tagged with
mermaidormmd(e.g., Gantt charts, flowcharts, Git graphs) will now automatically render as rich, interactive diagrams. - Improved Printing: Printed outputs and PDF exports will now always use the clean, highly-readable "snow" (light) theme, ensuring diagrams and text remain perfectly legible regardless of your active editor theme.
- Tuned Keyboard Controls: The leader-key system (used for Alt + T/F/D cycling) now disarms much faster (in 800 milliseconds instead of 2 seconds) once you finish cycling, meaning arrow keys return to normal text navigation almost immediately.
- Reorganized Shortcuts Dialog: The shortcuts dialog is now grouped by category (File, View, Style, Editor, App), supports Escape key dismissal, and can be toggled using the
Ctrl + .shortcut. - Updated Scratchpad: The welcome text has been refreshed with direct examples of KaTeX equations, Mermaid diagrams, and updated instructions.
Technical Details:
- Dynamic Imports & Code-Splitting: Dynamic dynamic-imports are used to lazy-load the heavy
katexandmermaidlibraries only when the parser detects math delimiters or diagram code blocks. Highlighting modules are also fetched via Vite'simport.meta.globon-demand to keep initial startup memory under 30 MB. - Marked Extensions: Custom tokenizers parse
blockMathandinlineMathbefore syntax highlighting or general markdown generation, parking raw TeX inside customdata-texattributes so that it survives DOMPurify HTML sanitization. - LRU Caching: Bounded LRU caches (
mathCachesize 256,mermaidCachesize 64) store rendered SVG/HTML output. This ensures active typing in the editor pane does not trigger redundant compilation passes for unmodified blocks. - Theme Parity for SVG Diagrams: Mermaid initializes dynamically with the correct light or dark variant. Theme shifts trigger
refreshForThemeChange(), which re-renders SVG nodes in-place without restarting the entire markdown compiler. Height pinning prevents layout layout-shifts and viewport scrolling jumps during async re-renders. - Print Override: Intercepts
window.print()to switch the top-level HTMLdata-themeattribute tosnowand awaits Mermaid theme refresh before letting the browser print the layout. Restores the user's active theme in anafterprintlistener. - Keyboard Chord Tuning: Modified
armLeaderinsidesrc/core/keyboard.jsto accept a custom timeout duration, updating the post-cycle re-arm to useLEADER_CYCLE_REARM_MS(800 ms) while leaving the initial chord window atLEADER_WINDOW_MS(2000 ms). - Test Coverage: Added
tests/preview/math-mermaid.test.jswritten in Vitest to run tokenization checks, false-positive currency guards, invalid math error boundaries, and integration sanitization checks under jsdom.