Created
December 16, 2016 12:51
-
-
Save manuelp/ed152fefc666c6d1cec0884bb3a7cba7 to your computer and use it in GitHub Desktop.
Markdown support for Emacs
This file contains hidden or 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
;; ========== Markdown | |
(use-package markdown-mode | |
:ensure t | |
:config | |
(setq markdown-coding-system "utf-8") | |
(add-hook 'markdown-mode-hook 'turn-off-auto-fill) | |
(add-hook 'markdown-mode-hook 'toggle-word-wrap) | |
;; Source: https://gist.github.com/edavis10/6084120 | |
(add-hook 'markdown-mode-hook | |
(lambda () | |
;; Open org-mode style links, [[file:relative.md]] | |
(local-set-key (kbd "C-c C-o") 'org-open-at-point-global))) | |
:mode (("\\.md" . markdown-mode) | |
("\\.markdown" . markdown-mode)) | |
:bind | |
(("C-c l" . markdown-follow-link-at-point))) | |
(use-package markdown-toc | |
:ensure t) | |
;; Automatic preview | |
;; Link: https://github.com/mola-T/flymd | |
(use-package flymd | |
:ensure t) | |
(defun markdown-to-html () | |
"Compiles the current file to HTML using Pandoc." | |
(interactive) | |
(let ((output-dir (read-directory-name "Output directory: ")) | |
(input-file (file-name-nondirectory buffer-file-name))) | |
(setq output-file (concat output-dir "/" (file-name-sans-extension input-file) ".html")) | |
(shell-command-on-region | |
(point-min) (point-max) | |
(concat "pandoc -f markdown -t html5 -Ss --toc --self-contained -c https://raw.githubusercontent.com/manuelp/pandoc-stylesheet/master/pub.css -o " output-file " " input-file)))) | |
(defun markdown-to-pdf () | |
"Compiles the current file to PDF using Pandoc." | |
(interactive) | |
(let ((output-dir (read-directory-name "Output directory: ")) | |
(input-file (file-name-nondirectory buffer-file-name))) | |
(setq output-file (concat output-dir "/" (file-name-sans-extension input-file) ".pdf")) | |
(shell-command-on-region | |
(point-min) (point-max) | |
(concat "pandoc -f markdown -Ss --toc --chapters --number-sections --variable papersize:a4paper --variable documentclass:article --variable colorlinks:blue -o " output-file " " input-file)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment