From mboxrd@z Thu Jan 1 00:00:00 1970 From: Christian Moe Subject: Re: ODT export custom link colors? Date: Wed, 14 Dec 2011 21:38:13 +0100 Message-ID: <4EE90935.7010402@christianmoe.com> References: Reply-To: mail@christianmoe.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-path: Received: from eggs.gnu.org ([140.186.70.92]:56550) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RavVY-0000ub-L0 for emacs-orgmode@gnu.org; Wed, 14 Dec 2011 15:32:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RavVX-00080l-Pl for emacs-orgmode@gnu.org; Wed, 14 Dec 2011 15:32:56 -0500 Received: from b1.hitrost.net ([91.185.211.67]:33096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RavVX-0007x6-Gp for emacs-orgmode@gnu.org; Wed, 14 Dec 2011 15:32:55 -0500 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: Gary Oberbrunner Cc: Orgmode Mailing List Hi, I'm not sure about this, because I don't really know the ODT spec, but I *think* you will have to define an ODT Character style for *each* color you want to use, using a consistent convention for naming these styles. 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. 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" path desc)) > (t > (format"BGCOLOR LINK (%s): {%s}{%s}" format path desc))))) > (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