org-mode uses current color theme to publish

emacs, org-mode

Solution

By default org-mode exports source code with inline style information based on your current theme. However by setting `org-html-htmlize-output-type` to `'css` rather than the default `'inline-css` the generated html will have classes corresponding to the faces used. You can then provide your own css to style the faces.

For example exporting a snippet with `org-html-htmlize-output-type` set to `'inline-css` gives the following:

<pre class="src src-sh">
<span style="color: #F0DFAF; font-weight: bold;">for</span> f<span style="color: #F0DFAF; font-weight: bold;"> in</span> *; <span style="color: #F0DFAF; font-weight: bold;">do</span>
    <span style="color: #93E0E3;">echo</span> $<span style="color: #DFAF8F;">f</span>
<span style="color: #F0DFAF; font-weight: bold;">done</span>
</pre>

While exporting the same snippet with `org-html-htmlize-output-type` set to `'css` gives:

<pre class="src src-sh">
<span class="org-keyword">for</span> f<span class="org-keyword"> in</span> *; <span class="org-keyword">do</span>
    <span class="org-builtin">echo</span> $<span class="org-variable-name">f</span>
<span class="org-keyword">done</span>
</pre> 

Problem

Org-mode has an awesome feature to colorize text in source code blocks. However, it uses the current colors of the emacs theme. I often use the dark zenburn theme, which will place some parts of Java in light colors. When I publish to HTML, the light colors are not readable. The workaround is to restart emacs and re-publish without loading a them. Any better way?

Original source