It is possible to specify text modifiers such as bold, italics, strikethrough, etc. in a .org file very easily (see link).
Similarly, is there any way to specify text color for just a small section of a .org file such that the text is appropriately colored in the exported html file? I think this would be quite useful while taking highlighted notes fast.
Expected behavior:
This is a sample sentence in normal text color.
<font color="red">
This is a sample sentence in red text color.
</font>
<font color="green">
This is a sample sentence in green text color.
</font>
You can use a macro:
#+MACRO: color @@html:<font color="$1">$2</font>@@
* This is a test
This is a sample sentence in normal text color.
{{{color(red,This is a sample sentence in red text color.)}}}
{{{color(green,This is a sample sentence in green text color.)}}}
with the limitation that the second argument cannot contain a comma (and maybe some other characters).
If you are annoyed by macros. Then add the following to your Emacs config,
(org-add-link-type
"color"
(lambda (path)
(message (concat "color "
(progn (add-text-properties
0 (length path)
(list 'face `((t (:foreground ,path))))
path) path))))
(lambda (path desc format)
(cond
((eq format 'html)
(format "<span style=\"color:%s;\">%s</span>" path desc))
((eq format 'latex)
(format "{\\color{%s}%s}" path desc)))))
example in org-mode:
- This is [[color:green][green text]]
- This is [[color:red][red]]
org-faq
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With