emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Coloured source code examples in --batch exports?


From: Stig Brautaset
Subject: [O] Coloured source code examples in --batch exports?
Date: Thu, 13 Jun 2019 16:20:37 +0100

Consider a file =foo.org= with the following content:

#+begin_src org :tangle foo.org
,#+begin_src emacs-lisp
  (defun foo (a b c)
    "A metasyntactic function that doesn't do much."
    (interactive)
    (message "foo"))
,#+end_src
#+end_src

I can export that to HTML and get a nicely colourized export like so:

#+begin_src sh :results output verbatim
/Applications/Emacs.app/Contents/MacOS/Emacs --file foo.org --eval '(progn 
(package-initialize) (org-html-export-to-html nil nil nil t) (kill-emacs))'
cat foo.html
#+end_src

#+RESULTS:
: <div class="org-src-container">
: <pre class="src src-emacs-lisp">(<span style="font-weight: 
bold;">defun</span> <span style="font-weight: bold;">foo</span> (a b c)
:   <span style="font-style: italic;">"A metasyntactic function that doesn't do 
much."</span>
:   (<span style="font-weight: bold;">interactive</span>)
:   (message <span style="font-style: italic;">"foo"</span>))
: </pre>
: </div>

However, I can't run it like that because I'm trying to run it headless
on CirleCI, where neither DISPLAY nor TERM environment variables are
set. (Yes, I'm trying to automate my blog publishing.)

Adding a ~--batch~ flag to the command makes the command run on
CircleCI, but I get a less colourful (and less pleasing) result. The
markup appears to only use /italic/ and *bold* styles now.

#+begin_src sh :results output verbatim
/Applications/Emacs.app/Contents/MacOS/Emacs --batch --file foo.org --eval 
'(progn (package-initialize) (org-html-export-to-html nil nil nil t) 
(kill-emacs))'
cat foo.html
#+end_src

#+RESULTS:
: <div class="org-src-container">
: <pre class="src src-emacs-lisp">(<span style="font-weight: 
bold;">defun</span> <span style="font-weight: bold;">foo</span> (a b c)
:   <span style="font-style: italic;">"A metasyntactic function that doesn't do 
much."</span>
:   (<span style="font-weight: bold;">interactive</span>)
:   (message <span style="font-style: italic;">"foo"</span>))
: </pre>
: </div>

Is there a way I can get the nicely coloured output while exporting in
~--batch~ mode?

Stig


PS: In reality I'm using Org's publishing setup, but it was easier to
create a minimal example using export than an ECM that involves having
to configure ~org-publish-project-alist~...



reply via email to

[Prev in Thread] Current Thread [Next in Thread]