HTML export: Add class to outline containers using property

The HTML_CONTAINER_CLASS property can now be used to add a property to
the outline container of a node.
This commit is contained in:
Carsten Dominik 2010-02-01 09:37:35 +01:00
parent dbbf76a8e3
commit e853e2d798
4 changed files with 29 additions and 3 deletions

View File

@ -1,6 +1,16 @@
2010-02-01 Carsten Dominik <carsten.dominik@gmail.com>
* org-html.el (org-html-level-start): Use the
`html-container-class' text property to set an additional class
for an outline container.
* org-exp.el (org-export-remember-html-container-classes): New
function.
(org-export-preprocess-string): Call
`org-export-remember-html-container-classes'.
* org.el (org-cycle): Mention level cycling in the docstring.
(org-default-properties): Add new property HTML_CONTAINER_CLASS.
* org-remember.el (org-remember-apply-template): Do file insertion
first.

View File

@ -1362,6 +1362,9 @@ on this string to produce the exported version."
;; Find all headings and compute the targets for them
(setq target-alist (org-export-define-heading-targets target-alist))
;; Find HTML special classes for headlines
(org-export-remember-html-container-classes)
;; Get rid of drawers
(org-export-remove-or-extract-drawers
drawers (plist-get parameters :drawers) backend)
@ -1590,6 +1593,17 @@ the current file."
(unless desc (insert "][" link))
(add-text-properties pos (point) props))))))
(defun org-export-remember-html-container-classes ()
"Store the HTML_CONTAINER_CLASS properties in a text property."
(goto-char (point-min))
(let (class)
(while (re-search-forward
"^[ \t]*:HTML_CONTAINER_CLASS:[ \t]+\\(\\S-+\\)" nil t)
(setq class (match-string 1))
(save-excursion
(org-back-to-heading t)
(put-text-property (point-at-bol) (point-at-eol) 'html-container-class class)))))
(defvar org-export-format-drawer-function nil
"Function to be called to format the contents of a drawer.
The function must accept three parameters:

View File

@ -2003,6 +2003,7 @@ When TITLE is nil, just close all open levels."
(org-close-par-maybe)
(let* ((target (and title (org-get-text-property-any 0 'target title)))
(extra-targets (assoc target org-export-target-aliases))
(extra-class (and title (org-get-text-property-any 0 'html-container-class title)))
(preferred (cdr (assoc target org-export-preferred-target-alist)))
(remove (or preferred target))
(l org-level-max)
@ -2066,8 +2067,9 @@ When TITLE is nil, just close all open levels."
(setq href (cdr (assoc (concat "sec-" snumber) org-export-preferred-target-alist)))
(setq suffix (or href snumber))
(setq href (or href (concat "sec-" snumber)))
(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
suffix level level href
(insert (format "\n<div id=\"outline-container-%s\" class=\"outline-%d%s\">\n<h%d id=\"%s\">%s%s</h%d>\n<div class=\"outline-text-%d\" id=\"text-%s\">\n"
suffix level (if extra-class (concat " " extra-class) "")
level href
extra-targets
title level level suffix))
(org-open-par)))))

View File

@ -12383,7 +12383,7 @@ but in some other way.")
"TABLE_EXPORT_FORMAT" "TABLE_EXPORT_FILE"
"EXPORT_FILE_NAME" "EXPORT_TITLE" "EXPORT_AUTHOR" "EXPORT_DATE"
"ORDERED" "NOBLOCKING" "COOKIE_DATA" "LOG_INTO_DRAWER"
"CLOCK_MODELINE_TOTAL" "STYLE")
"CLOCK_MODELINE_TOTAL" "STYLE" "HTML_CONTAINER_CLASS")
"Some properties that are used by Org-mode for various purposes.
Being in this list makes sure that they are offered for completion.")