init-markdown.el 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ;;; init-markdown.el --- .Emacs Configuration -*- lexical-binding: t -*-
  2. ;;; Commentary:
  3. ;;
  4. ;;; Code:
  5. (use-package markdown-mode
  6. :pin "MELPA"
  7. :mode (("\\.markdown\\'" . markdown-mode)
  8. ("\\.md\\'" . markdown-mode))
  9. :config
  10. ;;----------------------------------------------------------------------------
  11. ;; Generated HTML 5 and UTF-8 with Markdown
  12. ;;----------------------------------------------------------------------------
  13. (eval-after-load "markdown-mode"
  14. '(defalias 'markdown-add-xhtml-header-and-footer 'as/markdown-add-xhtml-header-and-footer))
  15. (defun as/markdown-add-xhtml-header-and-footer (title)
  16. "Wrap XHTML header and footer with given TITLE around current buffer."
  17. (goto-char (point-min))
  18. (insert "<!DOCTYPE html>\n"
  19. "<html>\n"
  20. "<head>\n<title>")
  21. (insert title)
  22. (insert "</title>\n")
  23. (insert "<meta charset=\"utf-8\" />\n")
  24. (when (> (length markdown-css-paths) 0)
  25. (insert (mapconcat 'markdown-stylesheet-link-string markdown-css-paths "\n")))
  26. (insert "\n</head>\n\n"
  27. "<body>\n\n")
  28. (goto-char (point-max))
  29. (insert "\n"
  30. "</body>\n"
  31. "</html>\n")))
  32. (provide 'init-markdown)
  33. ;;; init-markdown.el ends here