emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Rasmus <rasmus@gmx.us>
To: mail@christianmoe.com
Cc: n.goaziou@gmail.com, emacs-orgmode@gnu.org
Subject: Re: [ox-html] Multiple wraps around sections
Date: Sun, 16 Mar 2014 14:01:18 +0100	[thread overview]
Message-ID: <87pplm5mch.fsf@gmx.us> (raw)
In-Reply-To: <m2wqfuy2yf.fsf@uio.no> (Christian Moe's message of "Sun, 16 Mar 2014 09:15:04 +0100")

Hi Christian and Nicolas,

Christian Moe <mail@christianmoe.com> writes:

> Rasmus writes:
>
>> Is there any way I can easily get an /extra/ container around my
>> sections?
>
> You would probably want to create an export filter for sections. See the
> manual, Export > Advanced configuration > Filters.

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.  Thus, it'd obviously prefer not touch it.  Hence the
question.

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?)

>> Note, my knowledge of HTML(5) & CSS is very limited so maybe I'm
>> overlooking something obvious here.
>
> I don't think you're overlooking any way to add a container. 

Thanks, I also couldn't find anything else, examining ox-html.el.

> But since the exporter already provides a fair set of containers, it is
> possible that you are overlooking a way to accomplish whatever you want
> to do with the existing output and CSS.

Quite possibly.  I did HTML back in gymnasium, but I really haven't
followed the "trends" in this area.

—Rasmus

-- 
Evidence suggests Snowden used a powerful tool called monospaced fonts

  parent reply	other threads:[~2014-03-16 13:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-15 23:32 [ox-html] Multiple wraps around sections Rasmus
2014-03-16 10:01 ` Nicolas Goaziou
     [not found] ` <m2wqfuy2yf.fsf@uio.no>
2014-03-16 13:01   ` Rasmus [this message]
2014-03-16 13:23     ` Nicolas Goaziou
2014-03-16 14:02       ` Rasmus
2014-03-16 14:21         ` Nicolas Goaziou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87pplm5mch.fsf@gmx.us \
    --to=rasmus@gmx.us \
    --cc=emacs-orgmode@gnu.org \
    --cc=mail@christianmoe.com \
    --cc=n.goaziou@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).