From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jens Lechtenboerger Subject: Re: PATCH: Allow class attribute for headline in HTML export Date: Sun, 02 Dec 2018 20:29:45 +0100 Message-ID: <87ftvf20d2.fsf@informationelle-selbstbestimmung-im-internet.de> References: <87d0qj3hwu.fsf@informationelle-selbstbestimmung-im-internet.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:53101) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gTXfN-0002kR-BT for emacs-orgmode@gnu.org; Sun, 02 Dec 2018 14:44:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gTXR8-0006xd-4U for emacs-orgmode@gnu.org; Sun, 02 Dec 2018 14:29:55 -0500 Received: from mx1.mailbox.org ([2001:67c:2050:104:0:1:25:1]:15432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gTXR7-0006xF-P2 for emacs-orgmode@gnu.org; Sun, 02 Dec 2018 14:29:50 -0500 Received: from smtp1.mailbox.org (unknown [IPv6:2001:67c:2050:105:465:1:1:0]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by mx1.mailbox.org (Postfix) with ESMTPS id B006C44726 for ; Sun, 2 Dec 2018 20:29:47 +0100 (CET) Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter01.heinlein-hosting.de (spamfilter01.heinlein-hosting.de [80.241.56.115]) (amavisd-new, port 10030) with ESMTP id YZVmp8l1MgMq for ; Sun, 2 Dec 2018 20:29:46 +0100 (CET) In-Reply-To: <87d0qj3hwu.fsf@informationelle-selbstbestimmung-im-internet.de> (Jens Lechtenboerger's message of "Sun, 2 Dec 2018 19:25:21 +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" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain On 2018-12-02, at 19:25, Jens Lechtenboerger wrote: > Dear all, > > the attached patch allows to add a class attribute to headline > elements in HTML export. Is that acceptable for inclusion? In that patch, "when" should have been "if", sorry. Fixed version attached. Best wishes Jens --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-ox-html.el-New-property-HTML_HEADLINE_CLASS-for-clas.patch >From 068fb45f5276d61e86271988efbcf6c29e08c411 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Sun, 2 Dec 2018 20:25:38 +0100 Subject: [PATCH] ox-html.el: New property HTML_HEADLINE_CLASS for class of headline * lisp/ox-html.el (org-html-headline): Add new property HTML_HEADLINE_CLASS to assign class attribute to headline. * doc/org-manual.org: Document new property HTML_HEADLINE_CLASS. --- doc/org-manual.org | 6 +++++- lisp/ox-html.el | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index 458e59a4a..9d14c4cdc 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -12780,7 +12780,11 @@ external file. In order to add styles to a sub-tree, use the =HTML_CONTAINER_CLASS= property to assign a class to the tree. In order to specify CSS styles for a particular headline, you can use the ID specified in -a =CUSTOM_ID= property. +a =CUSTOM_ID= property or =HTML_HEADLINE_CLASS= as described next. + +#+cindex: @samp{HTML_HEADLINE_CLASS}, property +In order to assign a class to a headline, use the =HTML_HEADLINE_CLASS= +property. Never change the ~org-html-style-default~ constant. Instead use other simpler ways of customizing as described above. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 6a81be126..b043ab8fd 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2608,6 +2608,7 @@ holding contextual information." (format "\n" html-type)))) ;; Standard headline. Export it as a section. (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) + (headline-class (org-element-property :HTML_HEADLINE_CLASS headline)) (first-content (car (org-element-contents headline)))) (format "<%s id=\"%s\" class=\"%s\">%s%s\n" (org-html--container headline info) @@ -2616,9 +2617,12 @@ holding contextual information." (concat (format "outline-%d" level) (and extra-class " ") extra-class) - (format "\n%s\n" + (format "\n%s\n" level id + (if headline-class + (format " class=\"%s\"" headline-class) + "") (concat (and numberedp (format -- 2.17.1 --=-=-=--