JavaFXにはHTMLをレンダリングしてくれる WebView というコンポーネントがあるようです。
JavaのMarkdownプロセッサ PegDown と WebView を利用して Markdownファイルを画面に表示してみます。
;; leiningenでAOTコンパイルするファイルを指定 :aot [markdown-viewer.App]
;; App.clj
(ns markdown-viewer.App
(:import javafx.application.Application
javafx.scene.Scene
javafx.scene.control.Label
javafx.scene.web.WebView
javafx.stage.Stage
javafx.stage.FileChooser
javafx.stage.FileChooser$ExtensionFilter
[org.pegdown PegDownProcessor Extensions])
(:gen-class
:extends javafx.application.Application))
(defn md->html [^String source]
(let [parser (PegDownProcessor. Extensions/ALL)]
(.markdownToHtml parser source)))
(defn make-md-file-chooser ^FileChooser []
(let [fc (FileChooser.)]
(.setTitle fc "select Markdown file")
(-> fc .getExtensionFilters
(.add (FileChooser$ExtensionFilter. "Markdown" ["*.md" "*.markdown"])))
fc))
(defn load-html [^WebView wview ^String html]
(.loadContent (.getEngine wview) html))
(defn load-md [wview md]
(load-html wview (md->html md)))
(defn -start [this ^Stage stage]
(let [wview (WebView.)
fc (make-md-file-chooser)
;; ファイル選択
file (.showOpenDialog fc stage)]
(when file
(.setScene stage (Scene. wview 750 500))
(load-md wview (slurp file))
(.show stage))))
;; core.clj (ns markdown-viewer.core (require markdown-viewer.App) (:gen-class)) (defn -main [& args] (javafx.application.Application/launch markdown_viewer.App args))




