Re: [O] ODT export custom link colors?
Thanks guys -- I have it working. I do wish there was a way to define odt styles inline so I didn't have to edit my styles.xml but I guess that's unavoidable (?). I have the styles showing up in the odt style dialog, and my inline odt code invokes it from my custom link type. Thanks! -- -- Gary
Re: [O] ODT export custom link colors?
On 12/15/11 8:41 AM, Jambunathan K wrote: 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. Indeed, that's a better recipe. (On a Mac laptop keyboard, Cmd-T instead of F11.) The exact scenario you describe here is documented in the manual. (info "(org) Creating one-off styles") The scenario was not mixing raw ODT XML in with Org, but using a custom link type to color text. The manual page you point to gives all the info one would need to figure out how to do it, and I should have given the reference. But the manual does not spell out exactly how to solve that scenario, so I thought that would be helpful. #+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 That's cool, but how do you suggest to use it? I tried it with =:exports results=, but that didn't work (the angle brackets got escaped). But I probably misunderstood, and you meant to use it to generate the correct raw XML and then include the result in the text, with =@= signs added? That works out of the box for the "bold" example, but not for "red-style" -- I assume we'd have to create that style first? 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. Thanks, that's helpful. Yours, Christian
Re: [O] ODT export custom link colors?
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 > > --
Re: [O] ODT export custom link colors?
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\">%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
[O] ODT export custom link colors?
I use custom links like [[bgcolor:red][Warning!]] to add some color to my documents. I can export those colors to HTML and LaTeX like this: (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)) (t (format"BGCOLOR LINK (%s): {%s}{%s}" format path desc) ... but as you can see in the odt case I don't know what to put to get my colors to come through. Is there anything I can do there? Is it some kind of XML styling stanza? (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.) -- -- Gary