[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] [ox-html] Multiple wraps around sections
From: |
Rasmus |
Subject: |
Re: [O] [ox-html] Multiple wraps around sections |
Date: |
Sun, 16 Mar 2014 14:01:18 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) |
Hi Christian and Nicolas,
Christian Moe <address@hidden> 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