Created
July 26, 2023 18:01
-
-
Save dunossauro/e46824cb413387fabdd8020cc4dc811d to your computer and use it in GitHub Desktop.
Custom faces to emacs markdown mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(custom-set-faces | |
'(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.8 :foreground "#A3BE8C" :weight extra-bold)))) | |
'(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.4 :foreground "#EBCB8B" :weight extra-bold)))) | |
'(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.2 :foreground "#D08770" :weight extra-bold)))) | |
'(markdown-header-face-4 ((t (:inherit markdown-header-face :height 1.15 :foreground "#BF616A" :weight extra-bold)))) | |
'(markdown-header-face-5 ((t (:inherit markdown-header-face :height 1.11 :foreground "#b48ead" :weight extra-bold)))) | |
'(markdown-header-face-6 ((t (:inherit markdown-header-face :height 1.06 :foreground "#5e81ac" :weight extra-bold)))) | |
) |
To WYSIWYG:
(defvar nb/current-line '(0 . 0)
"(start . end) of current line in current buffer")
(make-variable-buffer-local 'nb/current-line)
(defun nb/unhide-current-line (limit)
"Font-lock function"
(let ((start (max (point) (car nb/current-line)))
(end (min limit (cdr nb/current-line))))
(when (< start end)
(remove-text-properties start end
'(invisible t display "" composition ""))
(goto-char limit)
t)))
(defun nb/refontify-on-linemove ()
"Post-command-hook"
(let* ((start (line-beginning-position))
(end (line-beginning-position 2))
(needs-update (not (equal start (car nb/current-line)))))
(setq nb/current-line (cons start end))
(when needs-update
(font-lock-fontify-block 3))))
(defun nb/markdown-unhighlight ()
"Enable markdown concealling"
(interactive)
(markdown-toggle-markup-hiding 'toggle)
(font-lock-add-keywords nil '((nb/unhide-current-line)) t)
(add-hook 'post-command-hook #'nb/refontify-on-linemove nil t))
;; Add a hook to markdown-mode
(add-hook 'markdown-mode-hook #'nb/markdown-unhighlight)
To change fonts on this face:
(custom-set-faces
'(markdown-header-face ((t (:inherit font-lock-function-name-face :weight bold :family "variable-pitch"))))
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example:
Based on this post: https://www.reddit.com/r/emacs/comments/10h9jf0/beautify_markdown_on_emacs/