]> code.delx.au - gnu-emacs/blobdiff - lisp/org/org-special-blocks.el
Copyright, license, and header fixes for Org.
[gnu-emacs] / lisp / org / org-special-blocks.el
index c09b27de895381e02439be6e2d5f1780e3db6b18..fc882a333967d445eccb636c8b9e6d6cff11c42d 100644 (file)
@@ -1,6 +1,4 @@
-;;; org-special-blocks.el --- Turn blocks into LaTeX envs and HTML divs
-
-;; Copyright (C) 2009, 2011  Free Software Foundation, Inc.
+;; Copyright (C) 2009-2012  Free Software Foundation, Inc.
 
 ;; Author: Chris Gray <chrismgray@gmail.com>
 
 ;; user to add this class to his or her stylesheet if this div is to
 ;; mean anything.
 
+(require 'org-html)
 (require 'org-compat)
 
+(declare-function org-open-par "org-html" ())
+(declare-function org-close-par-maybe "org-html" ())
+
 (defvar org-special-blocks-ignore-regexp "^\\(LaTeX\\|HTML\\)$"
   "A regexp indicating the names of blocks that should be ignored
 by org-special-blocks.  These blocks will presumably be
@@ -49,7 +51,7 @@ interpreted by other mechanisms.")
 (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 (eq org-export-current-backend 'html) 
+  (when (or (eq org-export-current-backend 'html)
            (eq org-export-current-backend 'latex))
     (goto-char (point-min))
     (while (re-search-forward "^[ \t]*#\\+\\(begin\\|end\\)_\\(.*\\)$" nil t)
@@ -82,11 +84,15 @@ seen.  This is run after a few special cases are taken care of."
   "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"))
+    (when (equal (match-string 2 line) "START")
+      (org-close-par-maybe)
+      (insert "\n<div class=\"" (match-string 1 line) "\">")
+      (org-open-par))
+    (when (equal (match-string 2 line) "END")
+      (org-close-par-maybe)
+      (insert "\n</div>")
+      (org-open-par))
     (throw 'nextline nil)))
 
 (add-hook 'org-export-html-after-blockquotes-hook