emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Special blocks: Make well-formed HTML
@ 2011-10-06  9:53 Christian Moe
  0 siblings, 0 replies; only message in thread
From: Christian Moe @ 2011-10-06  9:53 UTC (permalink / raw)
  To: Org Mode; +Cc: Carsten Dominik

* org-special-blocks.el
(org-special-blocks-convert-html-special-cookies): Close paragraph
before opening or closing the <div>, and open paragraph after. Also
changed newline placement to be the same as for other blocks.

The problem was that special blocks did not produce well-formed HTML
because they  wrapped the opening and closing
<div> tags in <p> tags.

TINYCHANGE

This patch only borrows a few lines from the handling of `CENTER'
blocks in org-export-as-html.

---
  lisp/org-special-blocks.el |   22 +++++++++++++---------
  1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/lisp/org-special-blocks.el b/lisp/org-special-blocks.el
index 2da57f0..f4e6258 100644
--- a/lisp/org-special-blocks.el
+++ b/lisp/org-special-blocks.el
@@ -78,15 +78,19 @@ seen.  This is run after a few special cases are 
taken care of."

  (defvar line)
  (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)))
+"Converts the special cookies into div blocks."
+;; Uses the dynamically-bound variable `line'.
+(when (string-match "^ORG-\\(.*\\)-\\(START\\|END\\)$" line)
+  (message "%s" (match-string 1))
+  (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
  	  'org-special-blocks-convert-html-special-cookies)
-- 
1.7.4.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-10-06  9:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-06  9:53 [PATCH] Special blocks: Make well-formed HTML Christian Moe

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).