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.
This commit is contained in:
Jens Lechtenboerger 2018-12-02 20:25:38 +01:00 committed by Nicolas Goaziou
parent 1eea78d1a5
commit 94d2dbf95f
3 changed files with 13 additions and 3 deletions

View File

@ -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.

View File

@ -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~.

View File

@ -2607,7 +2607,10 @@ holding contextual information."
(and (org-export-last-sibling-p headline info)
(format "</%s>\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</%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<h%d id=\"%s\">%s</h%d>\n"
(format "\n<h%d id=\"%s\"%s>%s</h%d>\n"
level
id
(if (not headline-class) ""
(format " class=\"%s\"" headline-class))
(concat
(and numberedp
(format