From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sacha Chua Subject: Re: TOC local for specified heading and its subheadings (in HTML export)? Date: Fri, 27 Nov 2015 23:58:17 -0500 Message-ID: <86si3qra8m.fsf@sachachua.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58864) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2Xai-0003bN-NT for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 23:58:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a2Xaf-0004cE-HT for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 23:58:32 -0500 Received: from plane.gmane.org ([80.91.229.3]:45675) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a2Xaf-0004Zg-AT for emacs-orgmode@gnu.org; Fri, 27 Nov 2015 23:58:29 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1a2XaY-00048A-PO for emacs-orgmode@gnu.org; Sat, 28 Nov 2015 05:58:22 +0100 Received: from 75-119-230-47.dsl.teksavvy.com ([75.119.230.47]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 Nov 2015 05:58:22 +0100 Received: from sacha by 75-119-230-47.dsl.teksavvy.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 28 Nov 2015 05:58:22 +0100 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 "D. C. Toedt" writes: Hello, D. C., all! > # ============= The next line is the desired feature: Generate a TOC list > (with links) of all subheadings in the specified heading > ===================== > #+TOC: headlines 1 local ConfInfoClauses This is totally a partial implementation since I've only bothered to make it work for HTML export, but someone can make it work nicely for everything else. =) I think it will permit the use of lines like: #+TOC: headlines 1 id:ConfInfoClauses diff --git a/lisp/ox-html.el b/lisp/ox-html.el index effd387..3b0e239 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2651,8 +2651,18 @@ CONTENTS is nil. INFO is a plist holding contextual information." ((string-match "\\" value) (let ((depth (and (string-match "\\<[0-9]+\\>" value) (string-to-number (match-string 0 value)))) - (localp (org-string-match-p "\\" value))) - (org-html-toc depth info (and localp keyword)))) + (localp (org-string-match-p "\\" value)) + (local-id (and (string-match "\\" value) + (match-string 1 value)))) + (org-html-toc depth info + (or + (and local-id + (car (org-element-map (plist-get info :parse-tree) + 'headline + (lambda (element) + (and (string= (org-element-property :CUSTOM_ID element) local-id) + element))))) + (and localp keyword))))) ((string= "listings" value) (org-html-list-of-listings info)) ((string= "tables" value) (org-html-list-of-tables info)))))))) D. C., are you okay with applying patches to your local copy, or do you need someone to clean it up and merge it into core? I have copyright assignment papers on file. Feel free to do what you want with the code! Sacha