Skip to content

⚡ JavaFX utility to preview Markdown in a separate window using Flexmark — perfect for developers building modern Java applications with live .md rendering support.

License

Notifications You must be signed in to change notification settings

raghul-tech/JavaFX-Markdown-Preview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaFX Markdown Preview Banner

JavaFX Markdown Preview

Maven Central GitHub Release Maven Build Status CodeQL Status Javadoc (1.0.1) Buy Me A Coffee


☕ About JavaFX Markdown Preview

JavaFX Markdown Preview is a modern and lightweight library designed to render Markdown content seamlessly in JavaFX applications.

Whether you’re building a Markdown editor, a documentation viewer, or just need a clean way to preview .md content inside your app — this tool saves you hours of work by offering a plug-and-play experience.

Why use this?

Plug-and-play setup – Integrate in just minutes
Live preview support – Automatically updates when the file changes
Cross-platform UI – Works on Windows, macOS, and Linux
Flexmark-powered – Renders CommonMark-compliant Markdown
No browser dependencies – Uses JavaFX WebView internally
Reusable – Add to any JavaFX or plain Java project easily

Whether you're developing documentation tools, note-taking apps, IDE plugins, or just need a Markdown viewer, this tool offers a ready-made and customizable solution.


✨ Features

  • 📂 Load .md file or raw Markdown string
  • 🔄 Real-time preview with file change detection
  • 🖥️ Opens in a separate JavaFX window
  • 🔁 Reopen preview window if closed
  • ☕ Supports both Java and JavaFX projects
  • ⚡ Lightweight and reusable as a utility

📦 Install via Maven

Add the dependency in your pom.xml:

<dependency>

  <groupId>io.github.raghul-tech</groupId>
  
  <artifactId>javafx-markdown-preview</artifactId>
  
  <version>1.0.1</version>
  
</dependency>

Or browse it on Maven Central.


🚀 Usage Example

  1. Load from Markdown File
import com.raghultech.markdown.preview.JavaFXMarkdownPreview;
import java.io.File;
import java.util.Scanner;

public class Markdown {
    public static void main(String[] args) {
        File file = new File("demo.md");
        JavaFXMarkdownPreview preview = new JavaFXMarkdownPreview(file);
        preview.launchPreview();

        Scanner scanner = new Scanner(System.in);

        while (true) {
            while (preview.isPreviewShowing()) {
                try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
            }

            System.out.print("Preview window closed. Reopen? (yes/no): ");
            String response = scanner.nextLine().trim().toLowerCase();

            if (response.equals("yes")) {
                preview.reopenWindow();
            } else {
                System.out.println("Exiting...");
                break;
            }
        }

        scanner.close();
        System.exit(0);
    }
}
  1. Load from Markdown String
import com.raghultech.markdown.preview.JavaFXMarkdownPreview;
import java.util.Scanner;

public class Markdown {
    public static void main(String[] args) {
        String content = "# ☕ JavaFX Markdown Preview\n\n" +
            "A simple and elegant **Markdown preview tool** using JavaFX and Flexmark.\n\n" +
            "---\n\n" +
            "## ✨ Features\n" +
            "- 📂 Load `.md` files or string input\n" +
            "- 🔄 Real-time file change detection\n" +
            "- 🖥️ Separate JavaFX window for previewing\n" +
            "- 🔁 Reopen preview window if closed\n";

        JavaFXMarkdownPreview preview = new JavaFXMarkdownPreview(content);
        preview.launchPreview();

        Scanner scanner = new Scanner(System.in);

        while (true) {
            while (preview.isPreviewShowing()) {
                try { Thread.sleep(1000); } catch (InterruptedException ignored) {}
            }

            System.out.print("Preview window closed. Reopen? (yes/no): ");
            String response = scanner.nextLine().trim().toLowerCase();

            if (response.equals("yes")) {
                preview.reopenWindow();
            } else {
                System.out.println("Exiting...");
                break;
            }
        }

        scanner.close();
        System.exit(0);
    }
}

💡 Run Using JAR

Compile:

javac -cp JavaFX-Markdown-Preview-1.0.1.jar Markdown.java

Run:

Windows:

java -cp .;JavaFX-Markdown-Preview-1.0.1.jar Markdown

Linux/macOS:

java -cp .:JavaFX-Markdown-Preview-1.0.1.jar Markdown

🧩 Requirements

  • Java 8 or above

  • JavaFX (use OpenJFX for Java 11+)

  • Maven for dependency management


🆕 Changelog:


⚠️ Known Issues

🔄 Real-Time Typing Issues

  • The preview may break briefly when typing fast due to background re-parsing.

  • Workaround: Pause briefly or trigger a manual refresh if needed.

😀 Emoji Rendering in Offline Environments

  • Emoji rendering depends on online font support (e.g., via web or CDN).

  • Offline systems may display missing glyphs or boxes.

  • This is a system font limitation, not a library bug.


🤝 Contributing

  • We welcome contributions of all kinds:

    • 🛠️ Bug fixes

    • 🌟 Feature suggestions

    • 📚 Documentation improvements

    • 🧪 More usage examples

Please check the Contributing Guide before starting.


🐞 Report a Bug

  • If you've encountered a bug, please report it by clicking the link below. This will guide you through the bug-reporting process: ➡️ Click here to report a bug

📄 License


📬 Contact

Email: raghultech.app@gmail.com


☕ Support

If you find this project useful, consider buying me a coffee!

Buy Me A Coffee

About

⚡ JavaFX utility to preview Markdown in a separate window using Flexmark — perfect for developers building modern Java applications with live .md rendering support.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages