Files
dotemacs/lisp/modes/markdown.el
2022-01-09 21:19:46 +01:00

92 lines
2.8 KiB
EmacsLisp

;;; markdown --- initializes Markdown modes -*- lexical-binding: t; -*-
;;; Commentary:
;;; Code:
(defconst *user-flymd-cache-directory*
(path-join *user-cache-directory* "flymd")
"Path to user's FLYMD cache store.")
(defun user--markdown-mode-hook ()
"Markdown mode hook."
(user/smartparens-enable)
;; org-mode table editing tools.
(orgtbl-mode t))
;; https://github.com/jrblevin/markdown-mode
;; Emacs Markdown Mode
(use-package markdown-mode
:defer
:hook (markdown-mode-hook . user--markdown-mode-hook)
:mode (("README\\.md\\'" . gfm-mode)
("\\.md\\'" . markdown-mode)
("\\.markdown\\'" . markdown-mode))
:config
(setq markdown-fontify-code-blocks-natively t)
(setq markdown-command "pandoc -f gfm --highlight-style kate")
(setq markdown-css-paths (list (path-join user-emacs-directory "markdown_style.css")))
(setq markdown-xhtml-body-preamble "\<article class=\"markdown-body\">")
;; Thanks to https://gist.github.com/yryozo/5807243
;; Orgtbl Translator function for the GitHub-Flavored-Markdown(GFM)
;; Usage Example:
;;
;; <!-- BEGIN RECEIVE ORGTBL ${1:YOUR_TABLE_NAME} -->
;; <!-- END RECEIVE ORGTBL $1 -->
;;
;; <!--
;; #+ORGTBL: SEND $1 orgtbl-to-gfm
;; | $0 |
;; -->
(defun orgtbl-to-gfm (table params)
"Convert the Orgtbl mode TABLE to GitHub Flavored Markdown."
(let* ((alignment (mapconcat (lambda (x) (if x "|--:" "|---"))
org-table-last-alignment ""))
(params2
(list
:splice t
:hline (concat alignment "|")
:lstart "| " :lend " |" :sep " | ")))
(orgtbl-to-generic table (org-combine-plists params2 params))))
;; https://github.com/mmark-md/flycheck-mmark
;; Flycheck checker for the MMark markdown processor
(use-package flycheck-mmark
:disabled
:if (executable-find "mmark")
:hook (flycheck-mode-hook . flycheck-mmark-setup))
;; https://github.com/polymode/poly-markdown
;; Polymode for markdown-mode
(use-package poly-markdown
:after polymode
:hook (markdown-mode-hook . poly-markdown-mode))
;; https://github.com/niku/markdown-preview-eww
;; Realtime markdown preview by eww
(use-package markdown-preview-eww)
;; https://github.com/ajtulloch/mkdown.el
;; A small library that improves the look of Markdown previews from Emacs, using the style of mkdown.com.
(use-package mkdown
:disabled
:config
(add-to-list 'markdown-css-paths mkdown-css-file-name))
;; https://github.com/shime/emacs-livedown
;; Emacs plugin for Livedown.
(use-package livedown
:disabled
:if (executable-find "livedown")
:quelpa (livedown
:fetcher github
:repo "shime/emacs-livedown")
:init
(require 'livedown)))
(provide 'modes/markdown)
;;; markdown.el ends here