更改 html 中从 org-mode 导出的文本颜色
Changing color of text in html export from org-mode
可以很容易地在 .org 文件中指定文本修饰符,例如粗体、斜体、删除线等 (see link)。
同样,是否有任何方法可以为 .org 文件的一小部分指定文本颜色,以便文本在导出的 html 文件中适当着色?我认为这在快速记录突出显示的笔记时非常有用。
预期行为:
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>
您可以使用 macro:
#+MACRO: color @@html:<font color=""></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.)}}}
限制是第二个参数不能包含逗号(可能还有一些其他字符)。
如果你对宏感到厌烦。然后将以下内容添加到您的 Emacs 配置中,
(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)))))
组织模式中的示例:
- This is [[color:green][green text]]
- This is [[color:red][red]]
可以很容易地在 .org 文件中指定文本修饰符,例如粗体、斜体、删除线等 (see link)。
同样,是否有任何方法可以为 .org 文件的一小部分指定文本颜色,以便文本在导出的 html 文件中适当着色?我认为这在快速记录突出显示的笔记时非常有用。
预期行为:
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>
您可以使用 macro:
#+MACRO: color @@html:<font color=""></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.)}}}
限制是第二个参数不能包含逗号(可能还有一些其他字符)。
如果你对宏感到厌烦。然后将以下内容添加到您的 Emacs 配置中,
(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)))))
组织模式中的示例:
- This is [[color:green][green text]]
- This is [[color:red][red]]