emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 3/3] add html attributes to special blocks.


From: John Kitchin
Subject: [O] [PATCH 3/3] add html attributes to special blocks.
Date: Mon, 28 Mar 2016 15:06:52 -0400

Enables #+attr_html and puts an id in when the special block is named.
---
 lisp/ox-html.el | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 5bdfc14..da67958 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3209,22 +3209,28 @@ contextual information."
   "Transcode a SPECIAL-BLOCK element from Org to HTML.
 CONTENTS holds the contents of the block.  INFO is a plist
 holding contextual information."
-  (let* ((block-type (org-element-property :type special-block))
-        (contents (or contents ""))
-        (html5-fancy (and (org-html--html5-fancy-p info)
-                          (member block-type org-html-html5-elements)))
-        (attributes (org-export-read-attribute :attr_html special-block)))
+  (let* ((block-type (downcase
+                      (org-element-property :type special-block)))
+         (contents (or contents ""))
+         (html5-fancy (and (org-html-html5-p info)
+                           (plist-get info :html-html5-fancy)
+                           (member block-type org-html-html5-elements)))
+         (attributes (org-export-read-attribute :attr_html special-block)))
     (unless html5-fancy
       (let ((class (plist-get attributes :class)))
-       (setq attributes (plist-put attributes :class
-                                   (if class (concat class " " block-type)
-                                     block-type)))))
+        (setq attributes (plist-put attributes :class
+                                    (if class (concat class " " block-type)
+                                      block-type)))
+        (when (org-element-property :name special-block)
+          (setq attributes (plist-put
+                            attributes :id
+                            (org-element-property :name special-block))))))
     (setq attributes (org-html--make-attribute-string attributes))
     (when (not (equal attributes ""))
       (setq attributes (concat " " attributes)))
     (if html5-fancy
-       (format "<%s%s>\n%s</%s>" block-type attributes
-               contents block-type)
+        (format "<%s%s>\n%s</%s>" block-type attributes
+                contents block-type)
       (format "<div%s>\n%s\n</div>" attributes contents))))
 
 ;;;; Src Block
-- 
2.4.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]