0

I'm trying to export simple org file to md format using command below:

emacs --batch myLanes.org --eval "(progn (require 'org) (org-export-as 'md))" > myLanes.md

I'm getting the error:

Unknown "nil" back-end: Aborting export

What could be wrong?

5
  • You will need to require ox-md as well: it is not loaded by default.
    – NickD
    Commented Aug 23, 2023 at 12:15
  • @NickD, yes it's better, not throwing an error now but the output file is empty :-( Commented Aug 23, 2023 at 15:33
  • Don't use stdout redirection: the file is written by the exporter, not printed to stdout.
    – NickD
    Commented Aug 23, 2023 at 15:43
  • @NickD, And where the exported does the export? I don't know whether I have another bug or suddenly get blinded as I can't see anything produced in the calling folder. Commented Aug 23, 2023 at 16:17
  • Right: org-export-as is not the right interface for this - try org-md-export-to-markdown. If the input file is myLanes.org, the output file will be myLanes.md in the same directory.
    – NickD
    Commented Aug 23, 2023 at 17:13

1 Answer 1

2

[Summarizing the back-and-forth in the comments]

Three problems:

  • By default the markdown exporter is not loaded.

  • The output of the export process can be a buffer or a file, but it is not the stdout of the Emacs process, so you cannot use output redirection.[1]

  • org-export-as is the generic interface that returns the transcoded output as a string. Higher-level interfaces create the output buffer or file. In this case, org-md-export-to-markdown is the higher-level interface that produces a file.

In summary, the invocation is:

emacs --batch myLanes.org \
      --eval "(progn (require 'org) (require 'ox-md) (org-md-export-to-markdown))"

That produces a file myLanes.md in the same directory as the input file myLanes.org (in this case, the current working directory , but you can use pathnames).


Footnote:

[1] Well, you can but you have to do it yourself, e.g. with (princ (org-export-as 'md)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.