#+TITLE: Export #+DESCRIPTION: Exporting Org files from orgstar to HTML, Markdown, PDF, Word, RTF and plain text, and to LaTeX, ODT and ASCII through Emacs; copying as rich text. #+LEDE: orgstar exports HTML, Markdown, PDF, Word, RTF and plain text itself, and hands LaTeX, ODT, ASCII and LaTeX-made PDF to Emacs on the Mac. * Exporting a file Export works on the file in the current editor, using its text as it is now, saved or not. It applies to Org files only; in any other file the command says "Not an org file". Source blocks are never run during export. Results already in the file are exported as they are; see [[file:11-code-blocks.org][Code blocks]]. ** On the Mac | Format | Command | Emacs preset | Doom | Needs Emacs | |--------------------+----------------------------------+---------------+-------------------------------+-------------| | HTML | Export to HTML | =C-c C-e h h= | =SPC m e h h=, =C-c C-e h h= | no | | HTML, then open it | Export to HTML and Open | =C-c C-e h o= | =SPC m e h o=, =C-c C-e h o= | no | | Markdown | Export to Markdown | =C-c C-e m m= | =SPC m e m m=, =C-c C-e m m= | no | | PDF | Export to PDF | — | — | no | | Word | Export to Word | — | — | no | | RTF | Export to RTF | — | — | no | | Plain text | Export to Plain Text | — | — | no | | PDF through LaTeX | Export to PDF with Emacs | =C-c C-e l p= | =SPC m e l p=, =C-c C-e l p= | yes | | LaTeX | Export to LaTeX with Emacs | =C-c C-e l l= | =C-c C-e l l= | yes | | ODT | Export to ODT with Emacs | =C-c C-e o o= | =C-c C-e o o= | yes | | ASCII text | Export to Plain Text with Emacs | =C-c C-e t u= | =C-c C-e t u= | yes | The keys follow Emacs's export dispatcher (=org-export-dispatch=). =C-c C-e= on its own is only a prefix: pause after it and the key hints list the formats. The =SPC m e= keys work in normal state; the =C-c C-e= keys work in every Doom state. The Mac preset has no keys for the single formats; its =⇧⌘E= opens the export dialog. All eleven commands are in File ▸ Export and in the command palette. They write the export beside the Org file, with the same name and the format's extension: =.html=, =.md=, =.pdf=, =.docx=, =.rtf=, =.tex=, =.odt= or =.txt=. =#+EXPORT_FILE_NAME:= names it instead, as in Org: relative to the Org file's folder (or absolute, or starting with =~=), with its extension replaced by the format's, so =#+EXPORT_FILE_NAME: out/report= writes =out/report.html=. A file already there is replaced. The message area shows "Exported to /name/". ** The export dialog *Export…* in the command palette, or =⇧⌘E= in the Mac preset, opens a dialog. The Emacs and Doom presets have no key for it; bind =app.export-dialog= in =keymap.toml= if you want one (see [[file:03-keys.org][Keys and commands]]). The dialog has: - *Format*: HTML, Markdown, PDF, Word, Rich Text (RTF), Plain text, PDF via LaTeX (Emacs), ODT (Emacs), LaTeX (Emacs) or Plain text, ASCII (Emacs). - *Scope*: the whole file, or the subtree at the caret (Org's =C-s= in the dispatcher). A subtree is exported as a document of its own: its heading is the title, its text the body, and its child headings move up a level. The file's =#+= keywords still apply, and the heading's =EXPORT_TITLE=, =EXPORT_AUTHOR=, =EXPORT_DATE=, =EXPORT_EMAIL=, =EXPORT_OPTIONS=, =EXPORT_SELECT_TAGS=, =EXPORT_EXCLUDE_TAGS=, =EXPORT_HTML_HEAD= and =EXPORT_HTML_HEAD_EXTRA= properties override them. Its planning line and property drawer are left out. The choice is available when the caret is under a heading. - *Body only*: leave out the title and the page around the text (Org's =C-b=). HTML is then the table of contents, the text and the footnotes, without ==, =
= or the title; Markdown has no title heading. Not available for PDF, Word, RTF, plain text and ODT. - *Destination*: where =#+EXPORT_FILE_NAME:= says, or the subtree's =EXPORT_FILE_NAME= property for a subtree, else beside the Org file. *Choose…* picks another place and name. Changing the format changes the extension. - *Open after export*: opens the file in its default app when the export finishes. The dialog remembers the format and the *Open after export* setting. ** On iOS The Export menu offers HTML, Markdown, PDF, Rich Text (RTF) and Plain Text, and Copy as Rich Text. It is under More in the editor, and in the toolbar in the reader. Choosing one opens the share sheet with the exported file, named after the Org file or its =#+EXPORT_FILE_NAME:=. Send it to another app, or use Save to Files to keep it. The export is the same as on the Mac. Word, LaTeX, ODT, ASCII and PDF through LaTeX are not available on iOS; RTF opens in Word and Pages. * HTML export orgstar writes a complete HTML page: a small built-in stylesheet that follows the system's light or dark appearance, the title, an author and date line, the table of contents, then the document. It does not use Emacs, and its output is close to, but not the same as, =ox-html=. ** Title, author and date | Keyword | Effect | |------------+--------------------------------------------------------------------------| | =#+TITLE:= | The page title and a top heading. Without one, the file's name is used. | | =#+AUTHOR:=| Shown under the title. | | =#+DATE:= | Shown under the title, after the author, as written. | Keywords in files named by =#+SETUPFILE:= count, as they do in Org. ** =#+OPTIONS= | Option | Values | Default | Effect | |---------+---------------------------------------+---------+------------------------------------------------------------------------| | =toc= | =t=, =nil=, a number | =t= | Table of contents, to the given depth. =t= goes to =H=. | | =num= | =t=, =nil=, a number | =t= | Section numbers, to the given depth. =t= goes to =H=. | | =H= | a number | =3= | The deepest heading level the table of contents and numbering count. | | =tags= | =t=, =nil=, =not-in-toc= | =t= | Heading tags; =not-in-toc= leaves them out of the table of contents. | | =todo= | =t=, =nil= | =t= | TODO keywords in headings. | | =pri= | =t=, =nil= | =nil= | Priority cookies in headings. | | =^= | =t=, =nil=, ={}= | =t= | =_= and =^= as subscripts and superscripts; ={}= only when braced, as in =x_{1}=. | | =tex= | =t=, =nil= | =t= | LaTeX fragments and environments; =nil= drops them. | | =title= | =t=, =nil= | =t= | The title heading. | | =author=| =t=, =nil= | =t= | The author. | | =date= | =t=, =nil= | =t= | The date. | A depth for =toc= or =num= larger than =H= is cut to =H=. Any value other than =nil= turns an option on. Other =#+OPTIONS= keys are ignored. #+BEGIN_SRC org ,#+TITLE: Field notes ,#+AUTHOR: Sam ,#+OPTIONS: toc:2 num:nil pri:t ^:{} #+END_SRC ** Which headings are exported - A heading tagged with one of =#+EXCLUDE_TAGS= (=noexport= by default) is left out, with everything under it. - A heading whose title starts with =COMMENT= is left out. - A heading tagged =ARCHIVE= is exported as the heading alone, without its contents. - If any heading has one of =#+SELECT_TAGS= (=export= by default), only those headings, their ancestors and everything under them are exported. Each heading gets an =id= for links: its =CUSTOM_ID= property, or a slug made from its title. Headings are one level down from Org's: a top-level heading is an =