[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[O] PATCH: Allow class attribute for headline in HTML export
From: |
Jens Lechtenboerger |
Subject: |
[O] PATCH: Allow class attribute for headline in HTML export |
Date: |
Sun, 02 Dec 2018 19:25:21 +0100 |
Dear all,
the attached patch allows to add a class attribute to headline
elements in HTML export. Is that acceptable for inclusion?
Best wishes
Jens
P.S. The change is tiny, but I assigned copyright to the FSF in
2015.
>From e8f16b04903bc32c4ea006727c82dbcb40b591a8 Mon Sep 17 00:00:00 2001
From: Jens Lechtenboerger <address@hidden>
Date: Sun, 2 Dec 2018 19:05:55 +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 | 5 ++++-
2 files changed, 9 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..d9d976753 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -2608,6 +2608,7 @@ holding contextual information."
(format "</%s>\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</%s>\n"
(org-html--container headline info)
@@ -2616,9 +2617,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
+ (when headline-class
+ (format " class=\"%s\"" headline-class))
(concat
(and numberedp
(format
--
2.17.1
- [O] PATCH: Allow class attribute for headline in HTML export,
Jens Lechtenboerger <=
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Jens Lechtenboerger, 2018/12/02
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Nicolas Goaziou, 2018/12/02
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Jens Lechtenboerger, 2018/12/03
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Nicolas Goaziou, 2018/12/04
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Jens Lechtenboerger, 2018/12/04
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Nicolas Goaziou, 2018/12/08
- Re: [O] PATCH: Allow class attribute for headline in HTML export, Jens Lechtenboerger, 2018/12/08