Hi,
I’m pretty sure there are other Emacs users around. If you’re tired of shortcodes being quite ugly in markdown-mode, here is a simple way to improve this: https://schnouki.net/post/2018/highlighting-hugo-shortcodes-in-emacs/
It allows you to fontify shortcodes, just like here:
You just need to add a few lines of Emacs Lisp to your Emacs config:
(defun schnouki/markdown-maybe-add-shortcode-keyword ()
"Enable fontifying Hugo shortcodes if in the ~/blog/ directory."
(when (string= (projectile-project-root) (expand-file-name "~/blog/"))
(let ((shortcode-regexp
(rx (group "{{" (or "<" "%") (1+ space)) ; opening {{< or {{%
(group (1+ (not space))) ; shortcode name
(group (*? any)) ; parameters
(group (1+ space) (? "/") (or ">" "%") "}}")))) ; closing >}}, %}}, />}} or /%}}
(font-lock-add-keywords nil `((,shortcode-regexp . ((1 'markdown-markup-face)
(2 'markdown-metadata-key-face)
(3 'markdown-metadata-value-face)
(4 'markdown-markup-face))))))))
(add-hook 'markdown-mode-hook #'schnouki/markdown-maybe-add-shortcode-keyword)
If your blog is not in ~/blog/
, or if you’re not using Projectile, you’ll need to edit the 3rd line so that it matches your install. Or you can just remove that line (and 1 parenthesis at the end of the function) to always enable that in markdown-mode
Feel free to tell me if it helps, or if it doesn’t work, or to ask if you have any question!