gpt4 book ai didi

org-mode - orgmode - 更改代码块背景颜色

转载 作者:行者123 更新时间:2023-12-02 09:11:31 31 4
gpt4 key购买 nike

下面的代码会将 html 导出背景颜色更改为#eff0fe:

#+ATTR_HTML: :style background-color:#eff0fe;
#+BEGIN_EXAMPLE
hello world!
#+END_EXAMPLE

如下所示: enter image description here

在emacs中编辑时如何改变背景颜色?

我看到了Pretty fontification of source code blocks文档,但听起来它对我不起作用!

最佳答案

另一种方法(我认为更通用)在this page中进行了解释。我已将代码片段复制粘贴到此处。它只会更改代码块,而不会更改 #+BEGIN#+END#+RESULTS 行。

下面的示例将使代码块相对于 emacs 主题的背景颜色变暗 3%(注意最后一个参数处的数字 3)。但是,如果您在编辑过程中更改主题,代码块的颜色将保持不变。

(require 'color)
(set-face-attribute 'org-block nil :background
(color-darken-name
(face-attribute 'default :background) 3))

使用浅色主题输出:

light

使用深色主题的输出:

dark

您可以进一步修改各个编程语言的代码块颜色。下面的示例将修改 emacs-lisp 和 python 的代码块颜色。

(setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
("python" (:background "#E5FFB8"))))

关于org-mode - orgmode - 更改代码块背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44811679/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com