From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Moe Subject: Re: ATTR_HTML for a clickable image, howto? Date: Sat, 07 Apr 2012 15:15:08 +0200 Message-ID: <4F803DDC.20808@christianmoe.com> References: <86pqbrywgr.fsf@iro.umontreal.ca> <87r4w63602.fsf@gnu.org> <86vclekyqo.fsf@iro.umontreal.ca> <4F7EAED9.2040804@christianmoe.com> Reply-To: mail@christianmoe.com Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([208.118.235.92]:51250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGVTX-0005p0-JT for emacs-orgmode@gnu.org; Sat, 07 Apr 2012 09:14:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SGVTV-0000LO-PQ for emacs-orgmode@gnu.org; Sat, 07 Apr 2012 09:14:43 -0400 Received: from b1.hitrost.net ([91.185.211.67]:52366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SGVTV-00088c-F6 for emacs-orgmode@gnu.org; Sat, 07 Apr 2012 09:14:41 -0400 In-Reply-To: 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: Samuel Wales Cc: =?UTF-8?B?RnJhbsOnb2lzIFBpbmFyZA==?= , emacs-orgmode@gnu.org Hi, Samuel, On 4/6/12 8:41 PM, Samuel Wales wrote: > Christian and others, > > Will CSS solutions described in this thread work if you always export > subtrees (not entire .org files) and never include style files? Yes, CSS styles apply to exported subtrees as well, whether from the default stylesheet, linked external stylesheets, or #+STYLE headers. But this applies to the static html files as exported by Org. If I understand your drift, you're thinking about using it in a content management system (CMS) like Blogger. A CMS will typically store only the content of your document and substitute its own template for the HEAD section where style information goes. Then these solutions won't work without modifying CSS in your CMS. > If so, how do you go about using them in Org? Is there a less awkward > way than using an HTML block with a div with style=? > This is awkward as you have to do it for every such block: > > #+HTML:
You can edit the CSS template of your CMS to take advantage of the classes and ids Org applies to its HTML exports. - You can also apply your own classes to subtrees using the :HTML_CONTAINER_CLASS: property, and style individual subtrees by id from :CUSTOM_ID:. - You can use #+ATTR_HTML to add class, id or style attributes to /some/ elements, and my understanding is that the new exporter that is in the works will help do this more systematically. - You can enclose blocks in custom block classes (
) with org-special-blocks (#+BEGIN_FOO), or with verbatim HTML. See the Org manual: - 12.5.9, "CSS support" Locally applying CSS to elements with the STYLE attribute, the very lowest level of the cascade, should be the last resort. > It would be great to have a generic style of some sort, specify the > scoped Org elements with neat syntax (maybe like [you meant to say:] #+begin_mycolor ... #+end_mycolor > instead of HTML blocks, and to be able to export it for subtrees (not > entire .org files!) in a completely self-contained way with no need to > include any file. Well, if you still want to apply local CSS formatting, but without writing verbatim HTML all the time, it gets a little more involved. Org-special-blocks doesn't help here as it only sets a class attribute for style sheets to select, it does not set the style attribute. Still: - You can simplify repeated use with macros. See the manual, section 11.6. Use the @ notation (section 12.5.3) for literal html tags within the macros. E.g.: #+MACRO: mycolor @$1@ {{{mycolor(Here I'd like some black text on an orange background.)}}} - You could probably also use Eric Schulte's contributed org-exp-blocks.el, but you'd need to write some code, and it might be overkill for this purpose. > An example use case is Blogger, where you /could/ try to change the > CSS for your template, but it is far better to have your post be > entirely self-contained with all the style information you need. Depends on your use case, I guess, but I think it would nearly always be a better, simpler, cleaner solution to modify your Blogger CSS. Yours, Christian