Below code will change html export background color to #eff0fe:
#+ATTR_HTML: :style background-color:#eff0fe;
#+BEGIN_EXAMPLE
hello world!
#+END_EXAMPLE
like below:
How can we change the background color when edit in emacs?
I saw Pretty fontification of source code blocks document but sounds like it doesn't work for me!
Another approach (which I think is more general) is explained in this page and I have copy-pasted the snippet here. It will only change the code block, and not the #+BEGIN
, #+END
, or #+RESULTS
lines.
The example below will darken the code block by 3 percent (notice the number 3 at the last parameter) relative to the background color of your emacs theme. However, if you change your theme during editing the color of the code block will stay the same.
(require 'color)
(set-face-attribute 'org-block nil :background
(color-darken-name
(face-attribute 'default :background) 3))
Output using a light theme:
Output using a dark theme:
You can modify further the code block color for individual programming language. The example below will modify the code block color for emacs-lisp and python.
(setq org-src-block-faces '(("emacs-lisp" (:background "#EEE2FF"))
("python" (:background "#E5FFB8"))))
Sounds like some face name changed, below config works:
(custom-set-faces
'(org-block-begin-line
((t (:underline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF" :extend t))))
'(org-block
((t (:background "#EFF0F1" :extend t))))
'(org-block-end-line
((t (:overline "#A7A6AA" :foreground "#008ED1" :background "#EAEAFF" :extend t))))
)
Output:
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