From 42c3e3600c22afadd5a1f1d884e9e8e0cb69e5f0 Mon Sep 17 00:00:00 2001 From: User Date: Sat, 30 May 2026 10:22:27 +0800 Subject: [PATCH] feat(markdown): Improve markdown editing experience - Enable native code block fontification - Add htmlize package for HTML export - Add custom theme faces for markdown-mode headers, code and tables - Remove Emacs 31+ tree-sitter mode remapping --- lisp/init-prog.el | 10 +++++----- lisp/my-base16-dark-theme.el | 8 ++++++++ lisp/my-base16-light-theme.el | 8 ++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/lisp/init-prog.el b/lisp/init-prog.el index 3f5724b..2f7f36e 100644 --- a/lisp/init-prog.el +++ b/lisp/init-prog.el @@ -46,11 +46,11 @@ :hook (markdown-mode . toggle-truncate-lines) :init - (setq markdown-command "multimarkdown") - (when (>= emacs-major-version 31) - (add-to-list 'major-mode-remap-alist - '(markdown-mode . markdown-ts-mode)) - (add-hook 'markdown-ts-mode-hook #'toggle-truncate-lines))) + (setq markdown-command "multimarkdown" + markdown-fontify-code-blocks-natively t)) + +;; html +(use-package htmlize) (provide 'init-prog) diff --git a/lisp/my-base16-dark-theme.el b/lisp/my-base16-dark-theme.el index 1291ded..a668486 100644 --- a/lisp/my-base16-dark-theme.el +++ b/lisp/my-base16-dark-theme.el @@ -39,6 +39,14 @@ `(cal-china-x-important-holiday-face ((,class (:underline (:style line :color ,red))))) `(cal-china-x-general-holiday-face ((,class (:underline (:style line :color ,yellow))))) `(holiday ((,class (:underline (:style line :color ,yellow))))) + `(markdown-header-face-1 ((,class (:foreground ,orange :height 1.0 :weight normal)))) + `(markdown-header-face-2 ((,class (:foreground ,blue :height 1.0 :weight normal)))) + `(markdown-header-face-3 ((,class (:foreground ,green :height 1.0 :weight normal)))) + `(markdown-header-face-4 ((,class (:foreground ,yellow :height 1.0 :weight normal)))) + `(markdown-header-face-5 ((,class (:foreground ,cyan :height 1.0 :weight normal)))) + `(markdown-header-face-6 ((,class (:foreground ,green :height 1.0 :weight normal)))) + `(markdown-code-face ((,class (:foreground ,base0)))) + `(markdown-table-face ((,class (:foreground ,green)))) `(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold)))) `(font-lock-doc-face ((,class (:foreground ,green :slant normal)))) `(font-lock-string-face ((,class (:foreground ,green)))) diff --git a/lisp/my-base16-light-theme.el b/lisp/my-base16-light-theme.el index 5ac0564..03bd1ed 100644 --- a/lisp/my-base16-light-theme.el +++ b/lisp/my-base16-light-theme.el @@ -39,6 +39,14 @@ `(cal-china-x-important-holiday-face ((,class (:underline (:style line :color ,red))))) `(cal-china-x-general-holiday-face ((,class (:underline (:style line :color ,yellow))))) `(holiday ((,class (:underline (:style line :color ,yellow))))) + `(markdown-header-face-1 ((,class (:foreground ,orange :height 1.0 :weight normal)))) + `(markdown-header-face-2 ((,class (:foreground ,blue :height 1.0 :weight normal)))) + `(markdown-header-face-3 ((,class (:foreground ,green :height 1.0 :weight normal)))) + `(markdown-header-face-4 ((,class (:foreground ,yellow :height 1.0 :weight normal)))) + `(markdown-header-face-5 ((,class (:foreground ,cyan :height 1.0 :weight normal)))) + `(markdown-header-face-6 ((,class (:foreground ,green :height 1.0 :weight normal)))) + `(markdown-code-face ((,class (:foreground ,base0)))) + `(markdown-table-face ((,class (:foreground ,green)))) `(font-lock-keyword-face ((,class (:foreground ,cyan :weight bold)))) `(font-lock-doc-face ((,class (:foreground ,green :slant normal)))) `(font-lock-string-face ((,class (:foreground ,green))))