From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nicolas Goaziou Subject: Re: [ox-html] Multiple wraps around sections Date: Sun, 16 Mar 2014 14:23:49 +0100 Message-ID: <87r462qntm.fsf@gmail.com> References: <87eh233unt.fsf@gmx.us> <87pplm5mch.fsf@gmx.us> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPB2F-0008KL-Hl for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 09:23:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WPB29-0007eY-MW for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 09:23:27 -0400 Received: from mail-wi0-x22d.google.com ([2a00:1450:400c:c05::22d]:60665) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WPB29-0007eS-Ec for emacs-orgmode@gnu.org; Sun, 16 Mar 2014 09:23:21 -0400 Received: by mail-wi0-f173.google.com with SMTP id f8so1155944wiw.12 for ; Sun, 16 Mar 2014 06:23:20 -0700 (PDT) In-Reply-To: <87pplm5mch.fsf@gmx.us> (rasmus@gmx.us's message of "Sun, 16 Mar 2014 14:01:18 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Rasmus Cc: emacs-orgmode@gnu.org, mail@christianmoe.com Hello, Rasmus 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 "\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