all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Coloured source code examples in --batch exports?
@ 2019-06-13 15:20 Stig Brautaset
  2019-06-13 20:16 ` Nick Dokos
  0 siblings, 1 reply; 3+ messages in thread
From: Stig Brautaset @ 2019-06-13 15:20 UTC (permalink / raw)
  To: emacs-orgmode

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Coloured source code examples in --batch exports?
  2019-06-13 15:20 Coloured source code examples in --batch exports? Stig Brautaset
@ 2019-06-13 20:16 ` Nick Dokos
  2019-06-13 21:34   ` Stig Brautaset
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Dokos @ 2019-06-13 20:16 UTC (permalink / raw)
  To: emacs-orgmode

Stig Brautaset <stig@brautaset.org> writes:

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

--batch skips your initialization file. You will have to provide a minimal
load file that does the initializations you need and then use -l to load it:

--8<---------------cut here---------------start------------->8---
emacs --batch -l my-init-file.el --file foo.org \
      --eval '(progn (package-initialize) (org-html-export-to-html nil nil nil t) (kill-emacs))'
--8<---------------cut here---------------end--------------->8---

-- 
Nick

"There are only two hard problems in computer science: cache
invalidation, naming things, and off-by-one errors." -Martin Fowler

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Coloured source code examples in --batch exports?
  2019-06-13 20:16 ` Nick Dokos
@ 2019-06-13 21:34   ` Stig Brautaset
  0 siblings, 0 replies; 3+ messages in thread
From: Stig Brautaset @ 2019-06-13 21:34 UTC (permalink / raw)
  To: Nick Dokos, emacs-orgmode

Nick Dokos <ndokos@gmail.com> writes:

> Stig Brautaset <stig@brautaset.org> writes:
>
>> ...
>> 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.
>>
>
> --batch skips your initialization file. You will have to provide a minimal
> load file that does the initializations you need and then use -l to load it:

Thank you. I did have a separate init file, but at the time I hadn't
figured out what to put in it! (I simplified my ECM too much!) However,
I've since discovered the magic org-html-htmlize-output-type variable
that does what I need.

My apologies for wasting people's time. I should have spent a bit more
time searching the archives, and less time building an ECM to
demonstrate something documented not to work!

Stig

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-13 21:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-13 15:20 Coloured source code examples in --batch exports? Stig Brautaset
2019-06-13 20:16 ` Nick Dokos
2019-06-13 21:34   ` Stig Brautaset

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.