feat: add plugin version to preview
This commit is contained in:
@@ -2,22 +2,17 @@ import Cocoa
|
|||||||
|
|
||||||
@main
|
@main
|
||||||
class AppDelegate: NSObject, NSApplicationDelegate {
|
class AppDelegate: NSObject, NSApplicationDelegate {
|
||||||
|
|
||||||
@IBOutlet var window: NSWindow!
|
@IBOutlet var window: NSWindow!
|
||||||
|
|
||||||
|
|
||||||
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
// Insert code here to initialize your application
|
// Insert code here to initialize your application
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationWillTerminate(_ aNotification: Notification) {
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
// Insert code here to tear down your application
|
// Insert code here to tear down your application
|
||||||
}
|
}
|
||||||
|
|
||||||
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ class PreviewViewController: NSViewController, QLPreviewingController, WKNavigat
|
|||||||
func preparePreviewOfFile(at url: URL) async throws {
|
func preparePreviewOfFile(at url: URL) async throws {
|
||||||
let cssUrl = try bundleFile(filename: "markdown", ext: "css")
|
let cssUrl = try bundleFile(filename: "markdown", ext: "css")
|
||||||
let md = try Document(parsing: url)
|
let md = try Document(parsing: url)
|
||||||
|
|
||||||
|
let ver = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String
|
||||||
|
let buildVer = Bundle.main.infoDictionary?["CFBundleVersion"] as! String
|
||||||
|
|
||||||
self.url = url
|
self.url = url
|
||||||
self.html = """
|
self.html = """
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
@@ -47,6 +51,10 @@ class PreviewViewController: NSViewController, QLPreviewingController, WKNavigat
|
|||||||
</head>
|
</head>
|
||||||
<body class="markdown-body">
|
<body class="markdown-body">
|
||||||
\(HTMLFormatter.format(md))
|
\(HTMLFormatter.format(md))
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
QLMarkdown v\(ver) (\(buildVer)) (Github: <a href="https://github.com/relikd/QLMarkdown">relikd/QLMarkdown</a>)
|
||||||
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
/* manually added: */
|
/* manually added: */
|
||||||
body{
|
body { padding: 20px 40px 10px; }
|
||||||
padding: 40px;
|
footer { font-size: 0.6em; color: #777; margin: 50px 0 0; text-align: center; }
|
||||||
}
|
|
||||||
|
|
||||||
/* Copied from https://github.com/sindresorhus/github-markdown-css */
|
/* Copied from https://github.com/sindresorhus/github-markdown-css (2025-12-04) */
|
||||||
.markdown-body {
|
.markdown-body {
|
||||||
--base-size-4: 0.25rem;
|
--base-size-4: 0.25rem;
|
||||||
--base-size-8: 0.5rem;
|
--base-size-8: 0.5rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user