Skip to content

Commit

Permalink
feat: preview markdown files via mdopen or grip
Browse files Browse the repository at this point in the history
  • Loading branch information
seagle0128 committed Aug 20, 2024
1 parent 3bfa6e8 commit 0d45ffe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lisp/init-markdown.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ mermaid.initialize({
(funcall fn)))
(advice-add #'markdown-export-and-preview :around #'my-markdown-export-and-preview))

;; Preview via `grip'
;; Install: pip install grip
;; Preview markdown files
;; @see: https://github.com/seagle0128/grip-mode?tab=readme-ov-file#prerequisite
(use-package grip-mode
:defines org-mode-map
:functions auth-source-user-and-password
Expand All @@ -110,10 +110,14 @@ mermaid.initialize({
(bind-key "C-c C-g" #'grip-mode org-mode-map))

(setq grip-update-after-change nil)
(when-let ((credential (and (require 'auth-source nil t)
(auth-source-user-and-password "api.github.com"))))
(setq grip-github-user (car credential)
grip-github-password (cadr credential))))

;; mdopen doesn't need credentials, and only support external browsers
(if (executable-find "mdopen")
(setq grip-use-mdopen t)
(when-let ((credential (and (require 'auth-source nil t)
(auth-source-user-and-password "api.github.com"))))
(setq grip-github-user (car credential)
grip-github-password (cadr credential)))))

;; Table of contents
(use-package markdown-toc
Expand Down

0 comments on commit 0d45ffe

Please sign in to comment.