From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jambunathan K Subject: Re: ODT export custom link colors? Date: Thu, 15 Dec 2011 13:11:46 +0530 Message-ID: <81d3bqjn7p.fsf@gmail.com> References: <4EE90935.7010402@christianmoe.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:35578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb5xC-0006pg-Bf for emacs-orgmode@gnu.org; Thu, 15 Dec 2011 02:42:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rb5x8-0006L4-Pd for emacs-orgmode@gnu.org; Thu, 15 Dec 2011 02:42:10 -0500 Received: from mail-iy0-f169.google.com ([209.85.210.169]:48168) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rb5x8-0006Kw-JM for emacs-orgmode@gnu.org; Thu, 15 Dec 2011 02:42:06 -0500 Received: by iacb35 with SMTP id b35so725964iac.0 for ; Wed, 14 Dec 2011 23:42:05 -0800 (PST) In-Reply-To: <4EE90935.7010402@christianmoe.com> (Christian Moe's message of "Wed, 14 Dec 2011 21:38:13 +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: mail@christianmoe.com Cc: Orgmode Mailing List , Gary Oberbrunner Christian Moe writes: > Hi, > > I'm not sure about this, because I don't really know the ODT spec, LibreOffice is my friend. > For instance, in the LibreOffice Styles and Formatting window, choose > the Character styles tab, right-click on Default, select New. Name > your style (e.g.) "Bgcolor red". Right-click it, select Modify, in the > Background tab give it a red background. I usually put the cursor on the text that I am interested in, press F11 and switch to char styles or whatever category. The right style would be highlighted which you can directly inherit from. > Repeat for other colors you use, e.g. "Bgcolor blue", "Bgcolor yellow"... > > Now, modify your custom link code as follows: > >> (org-add-link-type >> "bgcolor" nil >> (lambda (path desc format) >> (cond >> ((eq format 'html) >> (format"%s" path desc)) >> ((eq format 'latex) >> (format"\\colorbox{%s}{%s}" path desc)) > ((eq format 'odt) > (format " %s\">%s" path desc)) >> (t >> (format"BGCOLOR LINK (%s): {%s}{%s}" format path desc))))) >> The exact scenario you describe here is documented in the manual. (info "(org) Creating one-off styles") ^ C-x C-e here Look at item 1. The same node is here: http://orgmode.org/org.html#Creating-one_002doff-styles Instead of using an inline markup you can do something like this. #+begin_src emacs-lisp (org-odt-format-fontify "This text is in red" "red-style") #+end_src It will mark the text in "red-style". You can similarly use this or this for marking text in bold. #+begin_src emacs-lisp (org-odt-format-fontify "This text is in red" 'bold) #+end_src I believe you get the drift now. Note: There are lot more convenience functions that start with org-odt-format-* that I use internally to emit OpenDocument tags on the go. If you look at OrgOdtStyles.xml (C-h v org-odt-styles-dir) and you can see a bunch of styles marked as "Org Agenda Styles". These are used for marking TODO in red and DONE in green etc. Copy & paste those styles, fix the name and background color and you are done. > (You can change the style-name in the format string to follow whatever > naming convention you've adopted for your styles. If you want to call > them simply "red", "blue" and so on, it would be > text:style-name=\"%s\".) > > (Judging from the manual, if you have space in your style names, like > above, you should perhaps escape the spaces with _20_, but the > "Bgcolor %s" above seems to work fine.) > > Please report back if this works for you. If so, and depending on what > Jambunathan might have to add, I'll look into updating the Worg > examples. > >> (By the way, before I added my 't' case above, it returned nil, which >> caused the odt exporter to blow up with an unhelpful error. Would a >> patch for that be considered too much of a corner-case? I'd be happy >> to submit one.) > > I don't know what others think, but I think the habit of always > providing one's custom links with an explicit fallback should be > encouraged, if necessary by rude reminders from failing exporters... > :-) > > hth, > Christian > > --