From: Christian Moe <mail@christianmoe.com>
To: Gary Oberbrunner <garyo@oberbrunner.com>
Cc: Orgmode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: ODT export custom link colors?
Date: Wed, 14 Dec 2011 21:38:13 +0100 [thread overview]
Message-ID: <4EE90935.7010402@christianmoe.com> (raw)
In-Reply-To: <CAFChFyjKt+c5VfDDJcLH=k=gnX8ixkbVqWZ37G1sC+cbviK++w@mail.gmail.com>
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
next prev parent reply other threads:[~2011-12-14 20:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 17:34 ODT export custom link colors? Gary Oberbrunner
2011-12-14 20:38 ` Christian Moe [this message]
2011-12-15 7:41 ` Jambunathan K
2011-12-15 9:03 ` Christian Moe
2011-12-20 22:01 ` Gary Oberbrunner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EE90935.7010402@christianmoe.com \
--to=mail@christianmoe.com \
--cc=emacs-orgmode@gnu.org \
--cc=garyo@oberbrunner.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.