Hello, Rasmus <ras...@gmx.us> writes:
> The thing is semantics are pretty easy to mess up in HTML-like > languages compared to, say, LaTeX, since I have to figure out the > ending point. You don't have to figure that out. When using a headline filter, the first headline relative tag always opens the current headline and the last one always close it. Of course, this assumes that you can recognize a top level headline just by looking at its tags. > A short trial suggests that this filter does the job: > > #+begin_src html > (defun rasmus/org-html-headline-add-extra-div (headline backend info) > "Add an extra :html-container around top level sections." > (when (org-export-derived-backend-p backend 'html) > (let ((element > (plist-get (text-properties-at (next-property-change 0 headline) > headline) :parent))) > (when (= 1 (org-element-property :level element)) > (save-match-data > (string-match "\n" headline) > (concat > (replace-match > (format "\n<%s class=\"outline-container-top\">\n" > (org-html--container element info)) > t nil headline) > (format "</%s>\n" (org-html--container element info)))))))) > #+end_html > > The critical part is the next-property-change. I assume that the > first element is always the headline in question. > (Do you know if this is generally true, Nicolas?) This will not always work. Text properties only exist on raw text. If a headline do not contain raw text at all, like the following one, * =Verbatim= you will not get the correct element. Regards, -- Nicolas Goaziou