emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Giovanni Moretti <g.moretti@massey.ac.nz>
To: Eric Schulte <eric.schulte@gmx.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: How to activate pre.src in org-babel html output? Can only get class=example
Date: Mon, 20 Feb 2012 13:12:11 +1300	[thread overview]
Message-ID: <4F418FDB.3030706@massey.ac.nz> (raw)
In-Reply-To: <87mx8gtasa.fsf@gmx.com>

Hi Eric

>  My guess is that during export you get a message along the lines of
>  "htmlize is required for export".  Try explicitly loading htmlize.el
>  (in the contrib/lisp directory of org) and then re-exporting ...

You're spot on - importing htmlize.el did the trick. However, before importing 
it, there weren't any error messages about it being missing. All would work 
happily, but the source block didn't have the additional src and src-python tags.

To me, this seems like a bug or at least not ideal, as the src tag and the 
src-<language> tag are related to the HTML export of #+begin_src block, not on 
*how* the HTML is styled (i.e. by the user or htmlize).

For those searching the mailing list later:

; For pretty-printed formatted source code on HTML export,
; load htmlize.el in init.el or the emacs config file

(load-file "~/.emacs.d/orgmode/contrib/lisp/htmlize.el")

I've got the orgmode source in the .emacs.d directory so I can pull updates 
using git, otherwise look for contrib/lisp/htmlize.el in the main Emacs directory.

With htmlize.el loaded, exporting:
| #+begin_src python :results output :exports both
| print "Pi = ", 355/113.0
| #+end_src python

Results in the src block having the src and src-python CSS tags:
|<pre  class="src src-python">
|<span  style="color: #a020f0;">print</span>
|<span  style="color: #8b2252;">"Pi ="</span>, 355/113.0
|<pre  class="example">
| Pi =  3.14159292035

with an automatically added little "Python" flag box on the Python src block.

Some custom CSS can be used to make the src and output a little more distinct. A 
simple way is it place these lines at the top of the file:

#+style:<style>  pre.src  {background-color: #DDFFFF;}</style>
#+style:<style>  .example {background-color: #FFFFCC;}</style>

However, you have to be consistent about using #+begin_src blocks rather than 
just a colon or using begin_example at the beginning of lines for src fragments 
that don't output anything, otherwise Python src they'll come out with the 
output colouring. The keyboard shortcut (< s tab) for getting a 
#+begin_src---#+end_src block is handy here.

Although the example above relates to #+begin_src python blocks, the fix should 
work with other languages.

Cheers and thanks

Dr Giovanni Moretti | School of Engineering and Advanced Technology
Senior Lecturer     | Massey University, Palmerston North, New Zealand
Computer Science    | Ph +64-6-3505799x2474  Fax +64-6-3502259 - ZL2GX
http://seat.massey.ac.nz/moretti                G.Moretti@massey.ac.nz

      reply	other threads:[~2012-02-20  0:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-13  4:04 How to activate pre.src in org-babel html output? Can only get class=example Giovanni Moretti
2012-02-18 15:03 ` Eric Schulte
2012-02-20  0:12   ` Giovanni Moretti [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F418FDB.3030706@massey.ac.nz \
    --to=g.moretti@massey.ac.nz \
    --cc=emacs-orgmode@gnu.org \
    --cc=eric.schulte@gmx.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).