From f3e0c56d066af6cfaf91795608452a4e5960cfe3 Mon Sep 17 00:00:00 2001 From: blais Date: Tue, 22 Apr 2003 08:56:01 +0000 Subject: [PATCH] "" git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils@1285 929543f6-e4f2-0310-98a6-ba3bd3dd1d04 --- tools/editors/emacs/rst-mode.el | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tools/editors/emacs/rst-mode.el b/tools/editors/emacs/rst-mode.el index fa70c3dd7..0d08c00b2 100644 --- a/tools/editors/emacs/rst-mode.el +++ b/tools/editors/emacs/rst-mode.el @@ -33,6 +33,11 @@ ;; (append '(("\\.rst$" . rst-mode) ;; ("\\.rest$" . rst-mode)) auto-mode-alist)) +;; You can also bind a command to automate converting to HTML: +;; (defun user-rst-mode-hook () +;; (local-set-key-safe [(control c)(?9)] 'rst-html-compile)) +;; (add-hook 'text-mode-hook 'user-rst-mode-hook) + ;;; Code: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -678,5 +683,47 @@ entered.") t)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Conversion to HTML, using compile. + +;; You can add something like this at the end your document to customize: +;; .. Local Variables: *** +;; .. mode: rst *** +;; .. rst-html-stylesheet: "http://intranet/style.css" *** +;; .. End: *** + +(defvar rst-html-command "docutils_html --no-toc-backlinks" + "Command to convert an reST file to HTML.") + +(defvar rst-html-options "" + "Local file options for reST to HTML conversion. This is meant to be used +within a file's local variables.") + +(defvar rst-html-stylesheet nil + "Stylesheet for reST to HTML conversion. This variable is provided as a simple +convenience for local variables.") + +(defun rst-html-compile () + "Compile command to convert reST document into HTML." + (interactive) + (let* ((bufname (file-name-nondirectory buffer-file-name)) + (outname (file-name-sans-extension bufname)) + (ssheet + (or (and rst-html-stylesheet + (concat "--stylesheet=\"" rst-html-stylesheet "\"")) + "")) + ) + (make-variable-buffer-local 'compile-command) + (setq compile-command + (mapconcat 'identity + (list rst-html-command + ssheet rst-html-options + bufname (concat outname ".html")) + " ")) + (if compilation-read-command + (call-interactively 'compile) + (compile compile-command)) + )) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; rst-mode.el ends here -- 2.11.4.GIT