Преглед изворни кода

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.
Jens Lechtenboerger пре 6 година
родитељ
комит
94d2dbf95f
3 измењених фајлова са 13 додато и 3 уклоњено
  1. 3 1
      doc/org-manual.org
  2. 3 0
      etc/ORG-NEWS
  3. 7 2
      lisp/ox-html.el

+ 3 - 1
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.

+ 3 - 0
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~.

+ 7 - 2
lisp/ox-html.el

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