emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] ODT export custom link colors?


From: Christian Moe
Subject: Re: [O] ODT export custom link colors?
Date: Wed, 14 Dec 2011 21:38:13 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:6.0.2) Gecko/20110902 Thunderbird/6.0.2

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"<span style=\"background-color:%s;\">%s</span>"  path desc))
     ((eq format 'latex)
      (format"\\colorbox{%s}{%s}"  path desc))
    ((eq format 'odt)
(format "<text:span text:style-name=\"Bgcolor %s\">%s</text:span>" 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]