将组织模式导出为 HTML:就地着色

问题描述 投票:0回答:5

如何指定 Emacs Org-Mode 在将文件导出为 HTML 时应使用的一段文本的颜色?

例如

* Here is one bullet
  ** Here is another bullet
       Here is some text that I want in BOLD RED 
       Here is some other text that I want in the default face
html emacs org-mode
5个回答
7
投票

你没有说这是否是一次性的。如果您需要样式,css 样式表就有意义。要只执行您描述的一次操作,您可以在您的组织文件中包含红色的 HTML 指令,如下所示:

Here is some text that I want in *@@html:<font color = "red">@@BOLD RED@@html:</font>@@*

请参阅 Org 手册中的引用 HTML 标签部分。


7
投票

杰弗里给出了答案。然而,要添加额外的信息,请知道我正忙于在 GitHub 上创建一个 org-macros 项目,目标是让此类行为变得轻而易举。

该项目仍处于草稿阶段(宏无法正确导出到 LaTeX),完整的文档尚不可用(虽然没关系,但您应该查看 Org 源代码以了解真正的使用语法),但是如果您克隆 https://github.com/fniessen/org-macros,您应该能够使用“bgcolor”、“color”或“highlight”宏(在 INCLUDE'ing org-macros.setup 之后文件在您的组织文档中)。

你会写:

INCLUDE: path/to/org-macros.setup

Here is some text that I want in *{{{color(red, BOLD RED)}}}*.

当我将这些宏置于完成状态时,它们将适用于 HTML 和 LaTeX(至少)。


1
投票

您可以使用 HTML HEAD 选项将自定义 CSS 样式表链接到导出的 html 文档:

#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="style1.css" />

查看导出的 html 和分配给不同组织级别的类,您应该能够立即组合出一个相当简单的样式表。这里有一个很好的例子:https://gist.github.com/mowen/326524

这里有一个参考:http://orgmode.org/manual/CSS-support.html#CSS-support


1
投票

另一种方式。

* Here is one bullet
** Here is another bullet
#+begin_html 
Here is some text that I want in <span style='color:red'>BOLD RED</span>
#+end_html
Here is some other text that I want in the default face

0
投票

org-special-block-extras
为 org-mode 的 HTML 和 LaTeX 导出选项提供了几个方便的额外块;其中之一是使用
[[color:COLOR_NAME][text]]
就地着色,例如,

* Here is one bullet
  ** Here is another bullet
       Here is some text that I want in *[[color:red][BOLD RED]]*
       Here is some other text that I want in the default face

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.