docs/manual/guide/12-export.org
428 lines · 39481 bytes
1#+TITLE: Export
2#+DESCRIPTION: Exporting Org files from orgstar to HTML, Markdown, PDF, Word, RTF, plain text and iCalendar, and to LaTeX, ODT and ASCII through Emacs; copying as rich text.
3#+LEDE: orgstar exports HTML, Markdown, PDF, Word, RTF, plain text and iCalendar itself, and hands LaTeX, ODT, ASCII and LaTeX-made PDF to Emacs on the Mac.
4
5* Exporting a file
6
7Export 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]].
8
9** On the Mac
10
11| Format | Command | Emacs preset | Doom | Needs Emacs |
12|--------------------+----------------------------------+---------------+-------------------------------+-------------|
13| HTML | Export to HTML | =C-c C-e h h= | =SPC m e h h=, =C-c C-e h h= | no |
14| 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 |
15| Markdown | Export to Markdown | =C-c C-e m m= | =SPC m e m m=, =C-c C-e m m= | no |
16| PDF | Export to PDF | — | — | no |
17| Word | Export to Word | — | — | no |
18| RTF | Export to RTF | — | — | no |
19| Plain text | Export to Plain Text | — | — | no |
20| 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 |
21| LaTeX | Export to LaTeX with Emacs | =C-c C-e l l= | =C-c C-e l l= | yes |
22| ODT | Export to ODT with Emacs | =C-c C-e o o= | =C-c C-e o o= | yes |
23| ASCII text | Export to Plain Text with Emacs | =C-c C-e t u= | =C-c C-e t u= | yes |
24| iCalendar | Export to iCalendar | =C-c C-e c f= | =C-c C-e c f= | no |
25| iCalendar, every agenda file | Export Agenda Files to iCalendar | =C-c C-e c a= | =C-c C-e c a= | no |
26| iCalendar, agenda files in one | Combine Agenda Files into iCalendar | =C-c C-e c c= | =C-c C-e c c= | no |
27
28The 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.
29
30All fourteen 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=, =.txt= or =.ics=. The two agenda-file commands are the exceptions; see [[*iCalendar export][iCalendar export]]. =#+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/".
31
32The [[file:../install.org][Mac App Store version]] has the ten commands that don't need Emacs; File ▸ Export, the export dialog and the command palette leave out the other four, and a key bound to Export to PDF with Emacs runs Export to PDF. When the export file, or an =#+INCLUDE:= or =#+SETUPFILE:=, is outside your folders, orgstar first asks for access to its folder; for the export file, Save Elsewhere… instead picks another place. See [[file:../install.org][Install]].
33
34** The export dialog
35
36*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:
37
38- *Format*: HTML, Markdown, PDF, Word, Rich Text (RTF), Plain text, PDF via LaTeX (Emacs), ODT (Emacs), LaTeX (Emacs), Plain text, ASCII (Emacs) or iCalendar.
39- *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. iCalendar is the exception: there the subtree's heading is an entry like any other. 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.
40- *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 =<html>=, =<head>= or the title; Markdown has no title heading. Not available for PDF, Word, RTF, plain text, ODT and iCalendar.
41- *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.
42- *Margins*, *Font* and *Page numbers*, for PDF: see /PDF export/.
43- *Open after export*: opens the file in its default app when the export finishes.
44
45The dialog remembers the format and the *Open after export* setting. The PDF settings are =config.toml= settings, and apply to every PDF export.
46
47** On iOS
48
49The Export menu offers HTML, Markdown, PDF, Word, Rich Text (RTF), Plain Text and iCalendar, 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. LaTeX, ODT, ASCII and PDF through LaTeX are not available on iOS, nor are the agenda-file iCalendar exports.
50
51* HTML export
52
53orgstar 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=.
54
55** Title, author and date
56
57| Keyword | Effect |
58|------------+--------------------------------------------------------------------------|
59| =#+TITLE:= | The page title and a top heading. Without one, the file's name is used. |
60| =#+AUTHOR:=| Shown under the title. |
61| =#+DATE:= | Shown under the title, after the author, as written. |
62| =#+LANGUAGE:= | The page's =lang=, and the language of the words the export writes: the table of contents heading, =Figure N:= captions and the footnotes' label, as Org's =org-export-dictionary= translates them. Without one, =org-export-default-language= (=en=). |
63
64Keywords in files named by =#+SETUPFILE:= count, as they do in Org.
65
66** =#+OPTIONS=
67
68| Option | Values | Default | Effect |
69|---------+---------------------------------------+---------+------------------------------------------------------------------------|
70| =toc= | =t=, =nil=, a number | =t= | Table of contents, to the given depth. =t= goes to =H=. |
71| =num= | =t=, =nil=, a number | =t= | Section numbers, to the given depth. =t= goes to =H=. |
72| =H= | a number | =3= | The deepest heading level the table of contents and numbering count. |
73| =tags= | =t=, =nil=, =not-in-toc= | =t= | Heading tags; =not-in-toc= leaves them out of the table of contents. |
74| =todo= | =t=, =nil= | =t= | TODO keywords in headings. |
75| =pri= | =t=, =nil= | =nil= | Priority cookies in headings. |
76| =^= | =t=, =nil=, ={}= | =t= | =_= and =^= as subscripts and superscripts; ={}= only when braced, as in =x_{1}=. |
77| =tex= | =t=, =nil= | =t= | LaTeX fragments and environments; =nil= drops them. |
78| =title= | =t=, =nil= | =t= | The title heading. |
79| =author=| =t=, =nil= | =t= | The author. |
80| =date= | =t=, =nil= | =t= | The date. |
81
82A 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 by HTML export. iCalendar export also reads =<= (see /iCalendar/ below) and =-=, which is on by default and turns =---=, =--= and =...= into dashes and an ellipsis in the text it writes.
83
84#+BEGIN_SRC org
85,#+TITLE: Field notes
86,#+AUTHOR: Sam
87,#+OPTIONS: toc:2 num:nil pri:t ^:{}
88#+END_SRC
89
90** Which headings are exported
91
92- A heading tagged with one of =#+EXCLUDE_TAGS= (=noexport= by default) is left out, with everything under it.
93- A heading whose title starts with =COMMENT= is left out.
94- A heading tagged =ARCHIVE= is exported as the heading alone, without its contents.
95- If any heading has one of =#+SELECT_TAGS= (=export= by default), only those headings, their ancestors and everything under them are exported.
96
97Each 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 =<h2>=, since the title is the =<h1>=.
98
99** The page head
100
101Each =#+HTML_HEAD:= and =#+HTML_HEAD_EXTRA:= line goes into the page's =<head>= as written, in order. Use them for stylesheets and scripts:
102
103#+BEGIN_SRC org
104,#+HTML_HEAD: <link rel="stylesheet" href="notes.css">
105#+END_SRC
106
107The built-in stylesheet is always included first. Other =#+HTML_…= keywords are not used.
108
109** Math
110
111LaTeX fragments (=\(…\)=, =\[…\]=, =$…$=, =$$…$$=) and LaTeX environments are left in the page for MathJax. When the page has any, orgstar adds MathJax 3 from =cdn.jsdelivr.net=, so the page needs a network connection to show math. Entities such as =\alpha= become their characters.
112
113** Includes
114
115=#+INCLUDE:= inserts another file before export, as =org-export-expand-include-keyword= does. Paths are relative to the Org file.
116
117| Form | Effect |
118|-----------------------------------------------+-----------------------------------------------------------|
119| =#+INCLUDE: "part.org"= | The file's contents, read as Org; its includes are expanded too, up to eight levels. |
120| =#+INCLUDE: "part.org::*Heading"= | Only the subtree with that heading. |
121| =#+INCLUDE: "part.org::#custom-id"= | Only the subtree with that =CUSTOM_ID=. |
122| =#+INCLUDE: "code.sh" src sh= | The file in a source block. |
123| =#+INCLUDE: "log.txt" example= | The file in an example block. |
124| =#+INCLUDE: "page.html" export html= | The file in an export block. |
125| =quote=, =verse=, =center=, =comment= | The file in a block of that kind. |
126| =:lines "5-10"= | Only those lines; either end may be left out. |
127| =:minlevel 2= | Shift the included headings so the shallowest is at that level. |
128
129A file that cannot be read is replaced by an empty line.
130
131** Macros
132
133={{{name(arguments)}}}= is replaced before export (=org-macro-replace-all=).
134
135| Macro | Replaced by |
136|------------------------------+----------------------------------------------------------------------|
137| =#+MACRO: name text= | =text=, with =$1=, =$2=… replaced by the arguments. |
138| ={{{title}}}=, ={{{author}}}=, ={{{date}}}=, ={{{email}}}= | That keyword's value. |
139| ={{{keyword(NAME)}}}= | The value of =#+NAME:=. |
140| ={{{input-file}}}= | The Org file's name. |
141| ={{{property(NAME)}}}= | The value of property =NAME= of the entry the macro is in; =ITEM= gives the heading's title. Empty before the first heading. |
142| ={{{property(NAME,SEARCH)}}}= | The same for the entry =SEARCH= finds in this file: =*Title=, =#custom-id= or a title. |
143| ={{{n}}}=, ={{{n(name)}}}= | A counter, increased at each use. =n(name,-)= repeats the current value; =n(name,5)= sets it to 5. |
144| ={{{time(format)}}}= | The current time, formatted as =format-time-string= does. |
145
146Arguments are separated by commas; write =\,= for a literal comma. Macros defined with =(eval …)=, and macros orgstar does not know, become empty. =#+MACRO:= definitions in setup files count.
147
148** Footnotes
149
150Footnote references, named or inline (=[fn:: text]=), become numbered superscript links. The notes are collected in a Footnotes section at the end, numbered in the order they are first referenced, each with a link back. A reference without a definition is exported as written.
151
152** Tables
153
154An Org table becomes an HTML =<table>=. If it has rules, the rows before the first rule are the header (=<thead>=) and the rest the body. =#+CAPTION:= gives the table a caption. =#+TBLFM:= lines are not exported.
155
156A table.el table (one drawn with =+=, =-= and =|=) becomes a table with each cell's =colspan= and =rowspan=, and the lines in a cell joined with line breaks. If its drawing is not a well-formed table, it is exported as preformatted text.
157
158** Images and links
159
160A link to an image file without a description becomes an =<img>=. The image types are =png=, =jpg=, =jpeg=, =gif=, =svg=, =webp=, =bmp=, =tif=, =tiff= and =avif=. =#+ATTR_HTML:= before the paragraph adds attributes (=:width 300 :alt "Map"=); without an =:alt=, the file name is used.
161
162An image paragraph with =#+CAPTION:= or =#+ATTR_HTML:= becomes a =<figure>=; a caption is numbered "Figure 1:", "Figure 2:" and so on.
163
164Links to =.org= files point to the =.html= file of the same name. Links to headings (=[[*Heading]]=), to =CUSTOM_ID= targets and to radio targets point to the heading's or target's =id= on the page. =id:= links point to =#= and the ID. Other links are written as they are.
165
166** Source blocks and their results
167
168A source block is exported as =<pre><code class="language-LANG">=, with the code escaped and its common indentation removed. Code in a language the editor highlights is colored as the editor colors it: each token is a =<span>= with the class Emacs's htmlize gives its face (=org-keyword=, =org-string=, =org-comment=, =org-function-name=, =org-type=, =org-constant=, =org-property-name=, =org-variable-name=), and the page's stylesheet colors them with the theme's =syntax-= colors, light and dark. Other languages are exported plain; the =language-= class lets a script or stylesheet in =#+HTML_HEAD= highlight them. Noweb references are shown as written. Code references are covered in [[file:09-links.org][Links]]: labels come off the lines, =-n= and =+n= number them, and =[[(name)]]= links to the labelled line.
169
170The block's =:exports= header argument decides what appears. orgstar resolves it as running the block would: from the =#+begin_src= line, =#+HEADER:= lines, =header-args= properties and =#+PROPERTY:= lines (see [[file:11-code-blocks.org][Code blocks]]). Without one, it is =results= for =dot=, =plantuml=, =ditaa=, =gnuplot=, =latex= and =lilypond= blocks, as their Org defaults set it, and =code= for other languages.
171
172| =:exports= | Exported |
173|------------------+-------------------------------------------|
174| =code= | The code. |
175| =results= | The block's existing =#+RESULTS:=. |
176| =both= | The code, then the results. |
177| =none= | Nothing. |
178
179A =#+CALL:= line exports its existing results, never the call itself; =:exports code= or =none= on the call, or in the =header-args= properties where the call is, exports nothing. An inline =src_= block has =:exports results= by default: the ={{{results(…)}}}= after it is exported and its code is not. With =:exports code= the code is exported in =<code>= and the results are not; with =both=, both. An inline =call_= never appears itself, and the ={{{results(…)}}}= after it is always exported, whatever =:exports= says, as in Org.
180
181** Other blocks and elements
182
183| Org | HTML |
184|----------------------------------+-------------------------------------------------|
185| =#+begin_example= | =<pre>= |
186| =: = lines | =<pre class="example">= |
187| =#+begin_quote= | =<blockquote>= |
188| =#+begin_center= | =<div class="center">= |
189| =#+begin_verse= | =<p class="verse">=, lines and indentation kept |
190| =#+begin_export html= | Its contents, as they are |
191| =#+begin_export= other formats | Nothing |
192| =#+begin_comment= | Nothing |
193| =#+begin_NAME=, any other name | =<div class="NAME">= (a special block) |
194| =@@html:…@@= | Its contents, as they are; other back-ends' snippets are dropped |
195| Plain, numbered and description lists | =<ul>=, =<ol>=, =<dl>=; checkboxes as =[X]=, =[-]=, =[ ]= |
196| Timestamps | =<time datetime="…">= |
197| Inline tasks | =<div class="inlinetask">= with the title in bold |
198| Dynamic blocks | Their contents |
199| =-----= | =<hr>= |
200
201Comments, drawers, property drawers, planning lines, clock lines and keywords are not exported.
202
203** Citations
204
205HTML and Markdown export handle citations the same way; see Citations below.
206
207* PDF export
208
209Export to PDF makes the HTML export into a PDF, laid out and split into pages by the system's web engine as printing does. It needs neither Emacs nor TeX, and works on iOS. The PDF has what the HTML export has: the title, the byline, the table of contents, colored code, tables, images and math (MathJax, which needs a network connection). For the page:
210
211- Colors are always the light ones, whatever the system's appearance.
212- Pages are US Letter where that is the usual size and A4 elsewhere; on the Mac, the paper size set for printing.
213- Code blocks, tables, figures and quotes are kept on one page when they fit, and a heading is not left at the bottom of a page.
214- Margins are 50 points on every side (=pdf-margin= under =[orgstar]= in =config.toml=; Margins in the Export dialog).
215- The text is in the export's own font, or the family =pdf-font= names (Font in the dialog). Code stays monospaced.
216- Each page's number is centred in its bottom margin (=pdf-page-numbers=; Page numbers in the dialog). The numbers are annotations on the pages, so the table of contents and other links keep working.
217
218For typeset output with LaTeX's classes and packages, use Export to PDF with Emacs instead (see /Exporting through Emacs/).
219
220* Word, RTF and plain text
221
222Export to Word, Export to RTF and Export to Plain Text make the HTML export into a document of that kind, as the system reads HTML: headings, emphasis, links, colored keywords and code, lists, and tables. Word files (=.docx=) are written by orgstar itself, so tables come through as Word tables; RTF keeps them too on the Mac. On iOS, where the system's HTML reader keeps no tables, Word's tables are made from the HTML export's tables, with header cells bold and the cells' text without its styles; RTF and plain text there have the cells' text but no table. Plain text is the same text without its styles: list bullets and table cells are kept, separated by tabs. Fonts are Helvetica Neue for text and Menlo for code, and the colors are the light ones.
223
224In Word files, the title has Word's Title style and headings have its Heading 1 to Heading 6 styles, so Word's navigation pane, outline view and contents fields find them. Images from =file:= links come through as pictures, as wide as their pixels at 96 to the inch, scaled to =#+ATTR_HTML: :width= when it is set, and no wider than the page. PNG, JPEG and GIF go in as they are; other formats the system can read, such as HEIC, WebP and TIFF, go in as PNG. SVG and images at web addresses are left out. RTF and plain text have no images.
225
226For Org's own ASCII layout, with underlined headings and drawn tables, use Export to Plain Text with Emacs.
227
228** Copying as rich text
229
230*Copy as Rich Text* (the command palette on the Mac, the Export menu on iOS) puts the selection, or the whole file when nothing is selected, on the clipboard as HTML, RTF and plain text. Paste it into Mail, Pages, Word or a web form to get the formatted text. On iOS it copies the whole file.
231
232* Markdown export
233
234Markdown export writes GitHub-flavored Markdown:
235
236- =#+TITLE:= becomes a top =#= heading. Org headings are one level down: =*= is =##=. TODO keywords stay in the heading text, and tags are shown as inline code. Priority cookies are left out unless =#+OPTIONS= has =pri:t=.
237- Source blocks become fenced code blocks with the language; example blocks, =: = lines and table.el tables become fenced blocks without one.
238- Tables become pipe tables. A rule after the first row makes it the header; otherwise the header row is empty.
239- Checkboxes become task-list items (=- [x]=, =- [ ]=).
240- Footnotes become =[^1]= references with the notes at the end.
241- Quotes become =>= blocks. Verse lines end with two spaces.
242- Images become ==. Links to =.org= files, with or without =file:=, point to the =.md= file of the same name; a search option after =::= is dropped.
243- =#+begin_export= blocks for =markdown=, =md= or =html=, and =@@html:…@@= snippets, are copied as they are.
244- Underline, subscripts and superscripts are written as HTML tags.
245- =:exports= is handled as in HTML export.
246- Citations are handled as in HTML export.
247
248As in HTML export, =#+INCLUDE:= lines are expanded and macros replaced first, and =#+EXCLUDE_TAGS=, =#+SELECT_TAGS=, =COMMENT= headings and =ARCHIVE= tags decide which headings are exported (see /Which headings are exported/). Of the =#+OPTIONS=, Markdown export reads =todo=, =pri=, =tags=, =^= and =title=; the others do not apply. It writes no author or date.
249
250* iCalendar export
251
252iCalendar export writes the =.ics= file =org-icalendar-export-to-ics= writes, for calendar apps to read or subscribe to. Each heading can give:
253
254- a =VEVENT= for its =DEADLINE= and one for its =SCHEDULED= date, as =org-icalendar-use-deadline= and =org-icalendar-use-scheduled= say. Their summaries start with =DL: = and =S: =;
255- a =VEVENT= for each other timestamp in its title and text, active ones only unless =#+OPTIONS= has =<:t= or =<:inactive=;
256- a =VTODO= for a task, as =org-icalendar-include-todo= says. Its =DTSTART= is the scheduled date (with =todo-start= in =org-icalendar-use-scheduled=), its =DUE= the deadline (with =todo-due= in =org-icalendar-use-deadline=); without a scheduled date, a deadline with a =+= repeater starts its warning period before it. =STATUS= is =NEEDS-ACTION= or =COMPLETED=, and =PRIORITY= maps =A= to 1, =B= to 5 and =C= to 9.
257
258| Setting | Values | Default |
259|--------------------------------------+-----------------------------------------------------------------------------------------------+--------------------------------|
260| =org-icalendar-use-deadline= | =event-if-not-todo=, =event-if-todo=, =event-if-todo-not-done=, =todo-due=, separated by spaces | ="event-if-not-todo todo-due"= |
261| =org-icalendar-use-scheduled= | the same, with =todo-start= for =todo-due= | ="todo-start"= |
262| =org-icalendar-include-todo= | =nil=, =t= (tasks not done), =all=, =unblocked= (not done, without unfinished children, and not after an unfinished sibling under an =ORDERED= parent), or TODO keywords separated by spaces | ="nil"= |
263| =org-icalendar-combined-agenda-file= | the file Combine Agenda Files into iCalendar writes | ="~/org.ics"= |
264
265The summary is the heading's title, or its =SUMMARY= property. The description is the heading's text as Org's ASCII export writes it, filled to 70 columns, or its =DESCRIPTION= property; =LOCATION=, =CLASS=, =TIMEZONE= and =APPT_WARNTIME= (an alarm, minutes before a timed event) are read too. =CATEGORIES= lists the heading's tags and its category. An =ID= property is the =UID=; a heading without one gets a new random =UID= each time, as in Org with =org-icalendar-store-UID= nil. Repeaters become =RRULE= lines. Times are local times without a zone, as Org writes them by default; a =TIMEZONE= property of =UTC= writes them in UTC, and any other value names the zone (=TZID=).
266
267=#+ICALENDAR_EXCLUDE_TAGS:= lists tags whose subtrees are left out; =#+EXCLUDE_TAGS:= doesn't apply, so =noexport= subtrees are exported unless listed. =#+SELECT_TAGS=, =COMMENT= headings and =ARCHIVE= tags apply as in the other exports. =#+ICAL-TTL:= sets =X-PUBLISHED-TTL=, the refresh period, such as =PT1H=. The calendar is named after the file, its description is =#+TITLE:=, and its owner =#+AUTHOR:= or your full name. Lines longer than 75 characters are folded and lines end in CRLF, as RFC 5545 asks.
268
269Export Agenda Files to iCalendar writes an =.ics= beside each agenda file (see [[file:07-agenda.org][The agenda]]). Combine Agenda Files into iCalendar writes all their entries to one calendar named =OrgMode= at =org-icalendar-combined-agenda-file=. On iOS, the Export menu's iCalendar shares the current file's calendar.
270
271Differences from Org: diary sexps (=%%(…)= lines and =<%%(…)>= timestamps) are left out, as they need Emacs's =icalendar.el=. The other =org-icalendar-*= variables keep Org's defaults: alarms only from =APPT_WARNTIME=, categories =(local-tags category)=, the whole body as the description, and local times. Descriptions of tables with column groups or alignment cookies, center blocks and links to targets can differ from Org's in layout.
272
273* Publishing
274
275Publishing (=org-publish=) exports a folder of Org files to a folder of HTML or Markdown files, copies other files beside them, and can write a sitemap. Projects are =[[publish]]= tables in =config.toml=, as =org-publish-project-alist= entries are in Emacs:
276
277#+BEGIN_SRC toml
278[[publish]]
279name = "notes"
280base-directory = "~/notes"
281publishing-directory = "~/public_html"
282recursive = true
283auto-sitemap = true
284sitemap-title = "Notes"
285
286[[publish]]
287name = "static"
288base-directory = "~/notes"
289base-extension = "css\\|png\\|jpg"
290recursive = true
291publishing-directory = "~/public_html"
292publishing-function = "org-publish-attachment"
293
294[[publish]]
295name = "site"
296components = "notes static"
297#+END_SRC
298
299| Key | Value | Default |
300|------------------------+---------------------------------------------------------------------------------------------+-----------------------------|
301| =name= | The project's name | required |
302| =base-directory= | The folder of files to publish: absolute, =~/…=, or relative to the first folder in the sidebar | required |
303| =publishing-directory= | Where the published files go, the same way | required |
304| =base-extension= | The extension of the files to publish, an Emacs regexp such as ="css\\|png"=, or =any= | ="org"= |
305| =recursive= | Files in subfolders too | =false= |
306| =exclude= | An Emacs regexp on the file's path under =base-directory=; matching files are left out | |
307| =include= | More files, relative to =base-directory=, separated by spaces | |
308| =publishing-function= | =org-html-publish-to-html=, =org-md-publish-to-md= or =org-publish-attachment= (copied as they are), several separated by spaces | =org-html-publish-to-html= |
309| =body-only= | The export's body only | =false= |
310| =auto-sitemap= | Write a sitemap into =base-directory= and publish it with the rest | =false= |
311| =sitemap-filename= | The sitemap's name | ="sitemap.org"= |
312| =sitemap-title= | Its =#+TITLE= | ="Sitemap for project NAME"= |
313| =sitemap-style= | =tree= (folders nest) or =list= | ="tree"= |
314| =sitemap-sort-files= | =alphabetically= (by title), =chronologically= or =anti-chronologically= (by =#+DATE=, else the file's date), or =nil= | ="alphabetically"= |
315| =sitemap-sort-folders= | In a =list= sitemap: =ignore= (no folders), =first=, =last= or =nil= (mixed) | ="ignore"= |
316| =sitemap-ignore-case= | Sort titles ignoring case | =false= |
317| =components= | For a project of projects: the projects' names, separated by spaces | |
318
319Files whose names start with a dot are left out. An Org file publishes to the same path under =publishing-directory=, named by =#+EXPORT_FILE_NAME= when it has one, with links to other =.org= files pointing to their =.html=. The sitemap lists each file as a link with its =#+TITLE= (or its name), as Org's default sitemap does.
320
321On the Mac, File ▸ Publish has the commands, which are also in the command palette:
322
323| Command | Emacs preset | What it does |
324|-------------------------+---------------+------------------------------------------------------------|
325| Publish Project… | =C-c C-e P x= | Asks for a project and publishes it (=org-publish=) |
326| Publish All Projects | =C-c C-e P a= | =org-publish-all= |
327| Publish Current File | =C-c C-e P f= | The current file, in the first project that has it (=org-publish-current-file=) |
328| Publish Current Project | =C-c C-e P p= | The first project that has the current file (=org-publish-current-project=) |
329
330A file whose published copy is newer than it is skipped, as Org skips files that haven't changed; delete the copy to publish it again. The message area says how many files were published and how many were up to date. Differences from Org: preparation and completion functions, =:makeindex=, custom sitemap functions and the export options a project can set (=:with-toc=, =:html-head= and the rest) aren't read; set those with =#+OPTIONS= and the other keywords in the files, or a =#+SETUPFILE=. Publishing is on the Mac only.
331
332* Exporting through Emacs
333
334On the Mac, PDF, LaTeX, ODT and plain text exports are done by Emacs, with the =ox= functions Emacs's dispatcher uses:
335
336| Format | Function |
337|------------+-----------------------------|
338| PDF | =org-latex-export-to-pdf= |
339| LaTeX | =org-latex-export-to-latex= |
340| ODT | =org-odt-export-to-odt= |
341| Plain text | =org-ascii-export-to-ascii= |
342
343The [[file:../install.org][Mac App Store version]] doesn't run Emacs and has none of these exports.
344
345orgstar runs =emacs -Q --batch= in the Org file's folder. It opens the file, replaces its contents with the editor's current text without saving, and calls the function. Emacs writes the result beside the file, as it would itself; with a destination chosen in the export dialog, orgstar then moves it there. The message area shows "Exporting with Emacs…" and then "Exported to /name/".
346
347What you need:
348
349- Emacs, at =ORGSTAR_EMACS= or one of =/opt/homebrew/bin/emacs=, =/usr/local/bin/emacs=, =/Applications/Emacs.app/Contents/MacOS/Emacs=, =/run/current-system/sw/bin/emacs= or =/usr/bin/emacs=. Without it the export fails with "Emacs isn't installed, so this format can't be exported."
350- For PDF, a TeX installation that Emacs's LaTeX export can run. Emacs runs with your =PATH= plus =/opt/homebrew/bin=, =/usr/local/bin=, =/Library/TeX/texbin=, =/usr/bin= and =/bin=, the same as code blocks get, so =latexmk= and =pdflatex= from MacTeX or Homebrew are found when orgstar was opened from the Dock.
351
352Things to know:
353
354- =-Q= means Emacs does not load your init file. Your LaTeX classes, export settings and packages from it are not used; the export uses Org's defaults and what the file itself sets.
355- File-local variables are applied only when Emacs considers them safe.
356- =org-export-use-babel= is off, so no source blocks run.
357- An export that takes more than two minutes is stopped with "Emacs took too long to export."
358- Edit ▸ Cancel Running Task (=⌘.=) stops the export and shows "Export canceled". Starting another export or table recalculation in Emacs cancels the one that is running.
359- If Emacs fails, the message area shows the last line of its error output.
360
361To use your own Emacs configuration, or formats orgstar does not list, export from Emacs itself; see [[file:15-alongside-emacs.org][Alongside Emacs]].
362
363* Citations
364
365HTML and Markdown export process citations as Org's =basic= citation processor does (=oc-basic=).
366
367#+BEGIN_SRC org
368,#+bibliography: refs.bib
369,#+cite_export: basic author-year
370
371As shown in [cite:@smith2020], and again [cite/t:@smith2020; see @lee2019 p. 4].
372
373,#+print_bibliography:
374#+END_SRC
375
376** Bibliography files
377
378Each =#+bibliography:= line names one file, relative to the Org file, optionally in quotes. A file ending in =.json= is read as CSL-JSON; anything else is read as BibTeX, with =@string= abbreviations expanded and =@comment= and =@preamble= skipped. You can have several =#+bibliography:= lines; for a key in more than one file, the first file wins.
379
380** =#+cite_export:=
381
382=#+cite_export: PROCESSOR [BIBLIOGRAPHY-STYLE [CITATION-STYLE]]=.
383
384- With no =#+cite_export:=, or with =basic=, citations are processed.
385- With any other processor, such as =csl= or =biblatex=, orgstar leaves citations as they are written.
386- The citation style, which may include a variant (=text/bare=), is the default for citations that do not name one.
387
388** Citation styles
389
390A citation is =[cite:…]= or =[cite/style:…]= or =[cite/style/variant:…]=, holding one or more =@key= references separated by =;=. Each reference may have its own prefix and suffix, and the whole citation a common prefix and suffix.
391
392| Style | Output |
393|-------------------------------+-------------------------------------------------------------------------|
394| default (none given) | =(Author, Year)= |
395| =author=, =a= | =Author= |
396| =noauthor=, =na= | =(Year)= |
397| =text=, =t= | =Author (Year)= |
398| =note=, =ft= | A footnote holding the =text= form |
399| =numeric=, =nb= | =(1)=, numbered by the cited works sorted by author; three or more in a row as =1-3= |
400| =nocite=, =n= | Nothing; the work is still listed in the bibliography |
401
402| Variant | Effect |
403|----------------------+--------------------------------------------|
404| =bare=, =b= | No parentheses |
405| =caps=, =c= | Capitalized author |
406| =bare-caps=, =bc= | Both |
407
408Works by the same author in the same year get =a=, =b=, … after the year. A key not found in any bibliography file shows as =??= and =????=. Citations in the title are dropped.
409
410For =note= citations, the blank before the citation is removed and punctuation right after it moves in front of the footnote mark, as =org-cite-adjust-note= does.
411
412** The bibliography
413
414=#+print_bibliography:= is replaced by an entry for every cited work, sorted by author. The bibliography style from =#+cite_export:= sets the form:
415
416| Bibliography style | Entry |
417|------------------------+----------------------------------------------------------|
418| default | =Author (Year). /Title/, Publisher.= |
419| =plain= | =Surnames. Title, Publisher, Year.= |
420| =numeric= | =[1] Author, /Title/, Publisher, Year.= |
421
422The publisher part comes from the =publisher=, =journal=, =institution= or =school= field. Without =#+print_bibliography:= no bibliography is written.
423
424* What export does not do
425
426- Subtree and body-only export are in the export dialog only; the single-format commands export the whole file. There is no asynchronous export.
427- Source blocks are not run, and noweb references are not expanded.
428- Export settings in the dialog are not per file.