From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: [PATCH 1/3] add id attribute to example-block on html export. Date: Mon, 28 Mar 2016 15:06:50 -0400 Message-ID: <1459192012-82531-1-git-send-email-jkitchin@andrew.cmu.edu> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53782) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akcVB-0000w5-Eo for emacs-orgmode@gnu.org; Mon, 28 Mar 2016 15:07:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1akcV8-0002Hd-8O for emacs-orgmode@gnu.org; Mon, 28 Mar 2016 15:07:01 -0400 Received: from mail-qk0-x22a.google.com ([2607:f8b0:400d:c09::22a]:33071) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1akcV8-0002HW-4Q for emacs-orgmode@gnu.org; Mon, 28 Mar 2016 15:06:58 -0400 Received: by mail-qk0-x22a.google.com with SMTP id s5so125257303qkd.0 for ; Mon, 28 Mar 2016 12:06:58 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Cc: John Kitchin This allows you to hyperlink to the block. --- lisp/ox-html.el | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index d07cdcc..92de209 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2370,14 +2370,23 @@ contextual information." ;;;; Example Block -(defun org-html-example-block (example-block _contents info) +(defun org-html-example-block (example-block contents info) "Transcode a EXAMPLE-BLOCK element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." (if (org-export-read-attribute :attr_html example-block :textarea) (org-html--textarea-block example-block) - (format "
\n%s
" - (org-html-format-code example-block info)))) + (let ((attributes (org-export-read-attribute :attr_html example-block))) + (when (org-element-property :name example-block) + (setq attributes (plist-put + attributes :id + (org-element-property :name example-block)))) + (setq attributes (org-html--make-attribute-string attributes)) + (when (not (equal attributes "")) + (setq attributes (concat " " attributes))) + (format "
\n%s
" + attributes + (org-html-format-code example-block info))))) ;;;; Export Snippet -- 2.4.4