New file: contrib/lisp/org-special-blocks.el
Contributed by Chris Gray
This commit is contained in:
parent
412314ab2b
commit
dd1268dcac
|
@ -1,3 +1,7 @@
|
|||
2009-05-07 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* lisp/org-special-blocks.el: New file.
|
||||
|
||||
2009-04-08 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
* lisp/org-choose.el (org-choose-get-fn-map-group): Fix bug with
|
||||
|
|
|
@ -34,6 +34,7 @@ org-R.el --- Computation using the R language
|
|||
org-registry.el --- A registry for Org links
|
||||
org2rem.el --- Convert org appointments into reminders
|
||||
org-screen.el --- Visit screen sessions through Org-mode links
|
||||
org-special-blocks.el --- Turn blocks into LaTeX envs and HTML divs
|
||||
org-toc.el --- Table of contents for Org-mode buffer
|
||||
orgtbl-sqlinsert.el --- Convert Org-mode tables to SQL insertions.
|
||||
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
;;; org-special-blocks.el --- Turn blocks into LaTeX envs and HTML divs
|
||||
|
||||
;; Copyright (C) 2009 Chris Gray
|
||||
|
||||
;; Author: Chris Gray <chrismgray@gmail.com>
|
||||
|
||||
;; This file is not currently part of GNU Emacs.
|
||||
|
||||
;; This program is free software; you can redistribute it and/or
|
||||
;; modify it under the terms of the GNU General Public License as
|
||||
;; published by the Free Software Foundation; either version 2, or (at
|
||||
;; your option) any later version.
|
||||
|
||||
;; This program is distributed in the hope that it will be useful, but
|
||||
;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
;; General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program ; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
;;
|
||||
|
||||
;; This package generalizes the #+begin_foo and #+end_foo tokens.
|
||||
|
||||
;; To use, put the following in your init file:
|
||||
;;
|
||||
;; (require 'org-special-blocks)
|
||||
|
||||
;; The tokens #+begin_center, #+begin_verse, etc. existed previously.
|
||||
;; This package generalizes them (at least for the LaTeX and html
|
||||
;; exporters). When a #+begin_foo token is encountered by the LaTeX
|
||||
;; exporter, it is expanded into \begin{foo}. The text inside the
|
||||
;; environment is not protected, as text inside environments generally
|
||||
;; is. When #+begin_foo is encountered by the html exporter, a div
|
||||
;; with class foo is inserted into the HTML file. It is up to the
|
||||
;; user to add this class to his or her stylesheet if this div is to
|
||||
;; mean anything.
|
||||
|
||||
(defun org-special-blocks-make-special-cookies ()
|
||||
"Adds special cookies when #+begin_foo and #+end_foo tokens are
|
||||
seen. This is run after a few special cases are taken care of."
|
||||
(when (or htmlp latexp)
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t)
|
||||
(replace-match
|
||||
(if (equal (downcase (match-string 1)) "begin")
|
||||
(concat "ORG-" (match-string 2) "-START")
|
||||
(concat "ORG-" (match-string 2) "-END"))
|
||||
t t))))
|
||||
|
||||
(add-hook 'org-export-preprocess-after-blockquote-hook
|
||||
'org-special-blocks-make-special-cookies)
|
||||
|
||||
(defun org-special-blocks-convert-latex-special-cookies ()
|
||||
"Converts the special cookies into LaTeX blocks."
|
||||
(goto-char (point-min))
|
||||
(while (re-search-forward "^ORG-\\(.*\\)-\\(START\\|END\\)$" nil t)
|
||||
(replace-match
|
||||
(if (equal (match-string 2) "START")
|
||||
(concat "\\begin{" (match-string 1) "}")
|
||||
(concat "\\end{" (match-string 1) "}"))
|
||||
t t)))
|
||||
|
||||
(add-hook 'org-export-latex-after-blockquotes-hook
|
||||
'org-special-blocks-convert-latex-special-cookies)
|
||||
|
||||
(defun org-special-blocks-convert-html-special-cookies ()
|
||||
"Converts the special cookies into div blocks."
|
||||
;; Uses the dynamically-bound variable `line'.
|
||||
(when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line)
|
||||
; (org-close-par-maybe)
|
||||
(message "%s" (match-string 1))
|
||||
(if (equal (match-string 2 line) "START")
|
||||
(insert "<div class=\"" (match-string 1 line) "\">\n")
|
||||
(insert "</div>\n"))
|
||||
(throw 'nextline nil)))
|
||||
|
||||
(add-hook 'org-export-html-after-blockquotes-hook
|
||||
'org-special-blocks-convert-html-special-cookies)
|
||||
|
||||
(provide 'org-special-blocks)
|
||||
|
||||
;;; org-special-blocks.el ends here
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
* org.el (org-autoload): Fix autoloading of ascii export
|
||||
functions.
|
||||
(org-modules): Add org-special-blocks.
|
||||
|
||||
2009-05-06 Carsten Dominik <carsten.dominik@gmail.com>
|
||||
|
||||
|
|
|
@ -201,8 +201,9 @@ to add the symbol `xyz', and the package must have a call to
|
|||
(const :tag "C registry: A registry for Org links" org-registry)
|
||||
(const :tag "C org2rem: Convert org appointments into reminders" org2rem)
|
||||
(const :tag "C screen: Visit screen sessions through Org-mode links" org-screen)
|
||||
(const :tag "C toc: Table of contents for Org-mode buffer" org-toc)
|
||||
(const :tag "C special-blocks: Turn blocks into LaTeX envs and HTML divs" org-special-blocks)
|
||||
(const :tag "C sqlinsert: Convert Org-mode tables to SQL insertions" orgtbl-sqlinsert)
|
||||
(const :tag "C toc: Table of contents for Org-mode buffer" org-toc)
|
||||
(repeat :tag "External packages" :inline t (symbol :tag "Package"))))
|
||||
|
||||
(defcustom org-support-shift-select nil
|
||||
|
|
Loading…
Reference in New Issue