emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Stig Brautaset <stig@brautaset.org>
To: emacs-orgmode@gnu.org
Subject: Coloured source code examples in --batch exports?
Date: Thu, 13 Jun 2019 16:20:37 +0100	[thread overview]
Message-ID: <m2wohpwlyy.fsf@brautaset.org> (raw)

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	other threads:[~2019-06-13 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 15:20 Stig Brautaset [this message]
2019-06-13 20:16 ` Coloured source code examples in --batch exports? Nick Dokos
2019-06-13 21:34   ` Stig Brautaset

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=m2wohpwlyy.fsf@brautaset.org \
    --to=stig@brautaset.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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).