7

Beloved org-mode can be configured so that different headings (aka, entry titles) display with different colors depending on their nesting level, and so that they only show the final markup character instead of the whole string of them.

Is it possible to configure emacs so markdown mode also renders like this?

I notice markdown-mode lets you fold to show only headings, but they are all rendered in the same color, and littered with # characters.

3
  • I think it is designed to work as you expect out of the box, but the author has made all of the heading levels the same face -- i.e., :inherit markdown-header-face : github.com/defunkt/markdown-mode/blob/master/markdown-mode.el So, consider changing a few faces to different :foreground colors and see if that makes a difference -- markdown-header-face-1; markdown-header-face-2; markdown-header-face-3
    – lawlist
    Commented Aug 14, 2015 at 1:36
  • @Drew This is it. There is a customization subgroup that lets you tweak all the faces. Thanks! I'm still not sure how to suppress some of the # marks, but getting the colors right is the big one.
    – algal
    Commented Aug 14, 2015 at 5:00
  • For the # marks, customize the markdown-header-delimiter-face.
    – glucas
    Commented Aug 14, 2015 at 19:18

3 Answers 3

5

Markup hiding is now part of the current development version of Markdown mode. Markup for headings, but also bold, italics, links, code, etc. can be hidden and toggled interactively using C-c C-x C-m (M-x markdown-toggle-markup-hiding). I should note that this is slightly different than what you asked in your question: even the final hash mark is hidden. You can set the default state by customizing markdown-hide-markup.

Indeed, as lawlist mentioned in a comment, to change the colors you can customize the specific heading level faces: markdown-header-face-1 to markdown-header-face-6. These all inherit from markdown-header-face, which is why the default colors are all the same. Themes can certainly customize the colors to be different.

Also, variable height heading faces have been built in for a while now. Set markdown-header-scaling to t to enable that.

3

Colors and other attributes can be manually changed atleast:

Based on this:

  1. Click on a place where there is no text in the whole line.

  2. M-x customize-face

  3. Customize face (default ‘all faces’): Customize face (default ‘all faces’): appears in the buffer. RET

  4. find markdown-header-face-1, markdown-header-face-2, markdown-header-face-3, markdown-header-face-4 ...

  5. Click markdown-header-face-1 --> show all attributes' --> Change foregroundto what you want and then clickState` and save for future sessions.

  6. Same for other face levels.

Instead, you can write this in the init file:

(custom-set-faces
 ;; custom-set-faces was added by Custom.
 ;; If you edit it by hand, you could mess it up, so be careful.
 ;; Your init file should contain only one such instance.
 ;; If there is more than one, they won't work right.
 '(markdown-header-face-1 ((t (:inherit markdown-header-face :foreground "medium blue" :height 1.0))))
 '(markdown-header-face-2 ((t (:inherit markdown-header-face :foreground "medium blue" :height 1.0))))
 '(markdown-header-face-3 ((t (:inherit markdown-header-face :foreground "dark orange" :height 1.0))))
 '(markdown-header-face-4 ((t (:inherit markdown-header-face :foreground "dark cyan" :height 1.0)))))
0

I found this:

(custom-set-faces
 '(markdown-header-face ((t (:inherit font-lock-function-name-face :weight bold :family "variable-pitch"))))
 '(markdown-header-face-1 ((t (:inherit markdown-header-face :height 1.8))))
 '(markdown-header-face-2 ((t (:inherit markdown-header-face :height 1.4))))
 '(markdown-header-face-3 ((t (:inherit markdown-header-face :height 1.2)))))
1
  • exactly what I'm looking for, we can also customize additional attributes other than :height like :foreground, :background...
    – Gangula
    Commented Jul 6 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.