From 94d2dbf95fdb711f224ce6870d6b9552cc609414 Mon Sep 17 00:00:00 2001 From: Jens Lechtenboerger Date: Sun, 2 Dec 2018 20:25:38 +0100 Subject: [PATCH] ox-html: 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 (CSS support): Document new property HTML_HEADLINE_CLASS. --- doc/org-manual.org | 4 +++- etc/ORG-NEWS | 3 +++ lisp/ox-html.el | 9 +++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index b5b071386..231315a32 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -12813,10 +12813,12 @@ around them. Both of these approaches can avoid referring to an external file. #+cindex: @samp{HTML_CONTAINER_CLASS}, property +#+cindex: @samp{HTML_HEADLINE_CLASS}, property 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. You can also assign a specific class to +a headline with 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/etc/ORG-NEWS b/etc/ORG-NEWS index 046244788..f9bea4b56 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -42,6 +42,9 @@ See [[git:3367ac9457]] for details. ** New features *** Babel **** Add LaTeX output support in PlantUML +*** New property =HTML_HEADLINE_CLASS= in HTML export +The new property =HTML_HEADLINE_CLASS= assigns a class attribute to +a headline. *** Allow LaTeX attributes and captions for "table.el" tables Supported LaTeX attributes are ~:float~, ~:center~, ~:font~ and ~:caption~. diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 6a81be126..7c836f155 100644 --- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2607,7 +2607,10 @@ holding contextual information." (and (org-export-last-sibling-p headline info) (format "\n" html-type)))) ;; Standard headline. Export it as a section. - (let ((extra-class (org-element-property :HTML_CONTAINER_CLASS headline)) + (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 +2619,11 @@ holding contextual information." (concat (format "outline-%d" level) (and extra-class " ") extra-class) - (format "\n%s\n" + (format "\n%s\n" level id + (if (not headline-class) "" + (format " class=\"%s\"" headline-class)) (concat (and numberedp (format