/SwingFX-Markdown-Preview

๐Ÿ“š Swing+JavaFX Markdown preview! ๐Ÿ–ฅ๏ธ Panels/tabs/windows with ๐Ÿ”„ live reload, ๐Ÿ“ค HTML export (get rendered MDโ†’HTML), ๐Ÿ˜Š emojis, ๐ŸŒ“ themes. โš ๏ธ Swing only.

Primary LanguageJavaMIT LicenseMIT

๐Ÿ“ SwingFX-Markdown-Preview

Render rich, real-time Markdown previews inside Java Swing apps using JavaFX WebView.

โšก Fast. ๐Ÿ–ผ๏ธ Beautiful. ๐ŸŽฏ Real-Time. ๐ŸŒ“ Theme-Aware.

Maven Central Build Status CodeQL Security Javadoc Latest Release Buy Me A Coffee


โœจ Overview

SwingFX-Markdown-Preview is a modern library for rendering live, GitHub-style Markdown previews inside Java Swing applications.

It uses JavaFX WebView embedded inside Swing via JFXPanel to deliver smoother, more advanced rendering than traditional JEditorPane or HTMLEditorKit.


๐Ÿ’ผ What Makes It Special?

  • ๐Ÿ“ฆ Works inside any Swing app
  • ๐ŸŒ Uses JavaFX WebView via JFXPanel (not JavaFX stage)
  • ๐Ÿง  Real-time preview updates as the file changes
  • ๐ŸŽจ Theme support (light/dark toggle)
  • ๐Ÿงฉ Modular architecture (choose minimal or fat jar)
  • ๐Ÿงฐ Includes Flexmark (optionally) for Markdown parsing
  • โœ… Compatible with JavaFX 11+ and Java 8+

๐Ÿ“ฆ Available Modules

Artifact Name Includes Flexmark Includes JavaFX Use Case
swingfx-markdown-preview โŒ No โŒ No For Maven users with own setup
swingfx-markdown-preview-flexmark โœ… Yes โŒ No Add your own JavaFX separately
swingfx-markdown-preview-all โœ… Yes โœ… Yes Just works, no manual setup

๐Ÿš€ Installation

๐Ÿ› ๏ธ Option 1: All-in-One (Flexmark + JavaFX)

<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview-all</artifactId>
  <version>1.0.0</version>
</dependency>

- ๐Ÿ“ถ Option 2: Code + Flexmark (included flexmark)

<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview-flexmark</artifactId>
  <version>1.0.0</version>
</dependency>

<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>21.0.1</version>
</dependency>

<!-- Also include: javafx-web, javafx-swing, javafx-fxml, javafx-graphics, javafx-base -->

๐Ÿชถ Option 3: Minimal (bring your own Flexmark + JavaFX)

<dependency>
  <groupId>io.github.raghul-tech</groupId>
  <artifactId>swingfx-markdown-preview</artifactId>
  <version>1.0.0</version>
</dependency>

<dependency>
  <groupId>com.vladsch.flexmark</groupId>
  <artifactId>flexmark-all</artifactId>
  <version>0.64.8</version>
</dependency>

<dependency>
  <groupId>org.openjfx</groupId>
  <artifactId>javafx-controls</artifactId>
  <version>21.0.1</version>
</dependency>

<!-- Also include: javafx-web, javafx-swing, javafx-fxml, javafx-graphics, javafx-base -->

๐Ÿ’ก Key Features

  • โœ… Live File Monitoring: auto-refreshes when Markdown file changes

  • โœ… GitHub-Flavored Markdown (matches the style of GitHub's Markdown)

  • โœ… Theme Toggle: light or dark mode with .setDarkMode(true)

  • โœ… HTML Export: easily convert Markdown to clean, styled HTML strings

  • โœ… Emoji Support

  • โœ… Component Types:

    • MarkdownPanel
    • MarkdownTabbedview
    • MarkdownWindow
    • MarkdownRenderer (no GUI)
  • โœ… HTML export and emoji support

  • โœ… No JavaFX Stage needed


๐Ÿงช Quick Example

import io.github.raghultech.markdown.swingfx.preview.MarkdownWindow;
import java.io.File;

public class PreviewDemo {
    public static void main(String[] args) {
        File file = new File("README.md");
        MarkdownWindow preview = new MarkdownWindow(file);
        preview.setWindowTitle("Markdown Live Preview");
        preview.setWindowSize(700, 700);
      //  preview.isDarkMode(true);
        preview.launchPreview();
    }
}

๐ŸŽจ Theme Switching

  • Toggle dark mode anytime:
preview.setDarkMode(true); // dark mode ON
preview.setDarkMode(false); // light mode
  • Live updates automatically.

๐Ÿ“‚ How to Use the JAR

Compile:

javac -cp swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp.java

Run:

Windows:

java -cp .;swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp

macOS/Linux:

java -cp .:swingfx-markdown-preview-all-1.0.0.jar MyPreviewApp

๐Ÿ—๏ธ Example Projects

โœ… To run an example:

  1. Download or clone this repository.

  2. Navigate to examples/.

  3. Compile and run the desired file.


๐Ÿ” Documentation


๐Ÿ†• Changelog


๐Ÿค Contributing

  • We welcome all contributions!

    • ๐Ÿ› Bug fixes

    • โœจ Features

    • ๐Ÿ“ Documentation improvements

    • ๐Ÿงช Example enhancements

๐Ÿ‘‰ Contributing Guide


๐Ÿž Report a Bug


๐Ÿ“„ License


โ˜• Support