Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

org-mode uses current color theme to publish

Tags:

emacs

org-mode

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?

like image 790
justingordon Avatar asked Aug 29 '12 01:08

justingordon


People also ask

What does Org mode do?

Org Mode (also: org-mode; /ˈɔːrɡ moʊd/) is a document editing, formatting, and organizing mode, designed for notes, planning, and authoring within the free software text editor Emacs.

How do you save in Org mode?

To save the document, either press the save icon, or press C-x C-s, call it 1.org.

How do you use org reveal?

To load Org-reveal, type “M-x load-library”, then type “ox-reveal”. Now you can export this manual into Reveal. js presentation by typing “C-c C-e R R”. Open the generated “Readme.


1 Answers

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> 
like image 190
Phillip Dixon Avatar answered Oct 16 '22 08:10

Phillip Dixon