org-mailing-list.org: Add "What to do if you don't receive an answer"
[worg.git] / org-contrib / org-export-generic.org
blobea62a9a8a9dedceb7bea6e0c3992c8170911ed2b
1 #+TITLE:     org-export-generic.el -- export org files to anything!
2 #+OPTIONS:   ^:{} 
3 #+AUTHOR:    Wes Hardaker
4 #+STARTUP: odd
6 * Overview
8 org-export-generic is basically a simple translation system that
9 knows how to parse most of an org buffer and then add
10 various formatting prefixes before and after each section type.
12 * Using It
14 org-export-generic does its work by examining a property list stored
15 in =org-generic-alist=.  The pre-defined list currently includes a
16 simple text exporter, a simple html exporter, a wikipedia exporter,
17 an exporter to IETF internet-draft format, and a "demo" exporter which
18 shows off all of the potential variables you can set.
20 You can also dynamically add property lists of your own using the
21 org-set-generic-type function:
23 #+begin_src emacs-lisp
24    (org-set-generic-type
25     "really-basic-text" 
26     '(:file-suffix     ".txt"
27       :key-binding     ?R
28       :title-format "=== %s ===\n"
29       :body-header-section-numbers t
30       :body-header-section-number-format "%s) "
31       :body-section-header-prefix  "\n"
32       :body-section-header-suffix "\n"
33       :body-line-format "  %s\n"
34       :body-line-wrap   75
35       ))
36 #+end_src
38 *Note:* Upper case key-bindings are reserved for your use.  Lower case
39 key bindings may conflict with future export-generic publications.
41 Then run org-export (ctrl-c ctrl-e) and select generic or run
42 org-export-generic.  You'll then be prompted with a list of export types
43 to choose from, which will include your new type assigned to the key "R".
45 * Property List Definitions
47   The property list items that can be used to format the output are
48   defined in the table below.
50   Generally speaking, many parts are
51   often divided into sections such that every parsed org /thing/
52   frequently has 3 output specifiers too it.  E.G., /thing/ might have
53   /thing-prefix/, /thing-suffix and /thing-format/.  The first is a prefix
54   placed before the output contents, the second is a suffix and 
55   /thing-format/ is a format string where a %s is expected to be in
56   it.  There is a bit of redundancy with this triple combination but
57   it provides flexibility (and in a few places, it's actually needed
58   because the format string may be called multiple times and the
59   prefix and suffix only once).
61 *** Property List Value Types
63     Many of the property list values can be one of a different types.
64     In particular, all of the /prefix/ and /suffix/ tags can be one of
65     the following types:
67     - A string (e.g., "<foo>")
68     - A character, which gets repeated by the length of he line to be
69       converted.  This is most useful for headers where you wish to
70       place a line underneath the header text.  EG:
72 :     :header-prefix             ?=
74       Will produce:
76 :     Property List Value Types
77 :     =========================
78      
79       For this section.
81     - A list of the above two types.  The list elements will be taken
82       based on the order of the header indent amount (ie, the number
83       of asterisks).  The list can be a mix of types too:
84     
85 :     :header-prefix             (?= ?- "<h3>" "<h4>")
87 *** The Full List of Value Types:
89 ***** Configuration Tags:
91       |--------------+---------|
92       | TAG          | EXAMPLE |
93       |--------------+---------|
94       | :file-suffix | ".txt"  |
95       | :key-binding | ?d      |
96       |--------------+---------|
98 ***** Data Output Tags:
100       |--------------------------------+---------------------------------------------------------------|
101       | TAG                            | EXAMPLE                                                       |
102       |--------------------------------+---------------------------------------------------------------|
103       | :header-prefix                 | "<header>\n"                                                  |
104       | :header-suffix                 | "</header>\n"                                                 |
105       |                                |                                                               |
106       | :author-export                 | t                                                             |
107       | :tags-export                   | t                                                             |
108       |                                |                                                               |
109       | :drawers-export                | t                                                             |
110       |                                |                                                               |
111       |                                |                                                               |
112       | :title-prefix                  | ?=                                                            |
113       | :title-format                  | "<h1>%s</h1>\n"                                               |
114       | :title-suffix                  | ?=                                                            |
115       |                                |                                                               |
116       | :date-export                   | t                                                             |
117       | :date-prefix                   | "<date>"                                                      |
118       | :date-format                   | "<br /><b>Date:</b> <i>%s</i><br />"                          |
119       | :date-suffix                   | "</date>\n\n"                                                 |
120       |                                |                                                               |
121       | :toc-export                    | t                                                             |
122       | :toc-header-prefix             | "<tocname>\n"                                                 |
123       | :toc-header-format             | "__%s__\n"                                                    |
124       | :toc-header-suffix             | "</tocname>\n"                                                |
125       |                                |                                                               |
126       | :toc-prefix                    | "<toc>\n"                                                     |
127       | :toc-suffix                    | "</toc>\n"                                                    |
128       |                                |                                                               |
129       | :toc-section-numbers           | t                                                             |
130       | :toc-section-number-format     | "\#(%s) "                                                     |
131       | :toc-format                    | "--%s--"                                                      |
132       | :toc-format-with-todo          | "!!%s!!\n"                                                    |
133       | :toc-indent-char               | ?\                                                            |
134       | :toc-indent-depth              | 4                                                             |
135       |                                |                                                               |
136       | :toc-tags-export               | t                                                             |
137       | :toc-tags-prefix               | "   <tags>"                                                   |
138       | :toc-tags-format               | "*%s*"                                                        |
139       | :toc-tags-suffix               | "</tags>\n"                                                   |
140       | :toc-tags-none-string          | "\n"                                                          |
141       |                                |                                                               |
142       | :body-header-section-numbers   | 3    ; t = all, nil = none                                    |
143       |                                |                                                               |
144       | :body-section-header-prefix    | ("<h1>" "<h2>" "<h3>" "<h4>" "<h5>" "<h6>")                   |
145       | :body-section-header-format    | "%s"                                                          |
146       | :body-section-header-suffix    | ("</h1>\n" "</h2>\n" "</h3>\n" "</h4>\n" "</h5>\n" "</h6>\n") |
147       |                                |                                                               |
148       | :timestamps-export             | t                                                             |
149       | :priorities-export             | t                                                             |
150       | :todo-keywords-export          | t                                                             |
151       |                                |                                                               |
152       | :body-tags-export              | t                                                             |
153       | :body-tags-prefix              | "  <tags>"                                                    |
154       | :body-tags-suffix              | "</tags>\n"                                                   |
155       |                                |                                                               |
156       | :body-section-prefix           | "<secprefix>\n"                                               |
157       | :body-section-suffix           | "</secsuffix>\n"                                              |
158       |                                |                                                               |
159       |                                |                                                               |
160       | :body-line-export-preformated  | t                                                             |
161       | :body-line-fixed-prefix        | "<pre>\n"                                                     |
162       | :body-line-fixed-suffix        | "\n</pre>\n"                                                  |
163       | :body-line-fixed-format        | "%s\n"                                                        |
164       |                                |                                                               |
165       |                                |                                                               |
166       | :body-list-prefix              | "<list>\n"                                                    |
167       | :body-list-suffix              | "</list>\n"                                                   |
168       | :body-list-format              | "<li>%s</li>\n"                                               |
169       |                                |                                                               |
170       | :body-number-list-prefix       | "<ol>\n"                                                      |
171       | :body-number-list-suffix       | "</ol>\n"                                                     |
172       | :body-number-list-format       | "<li>%s</li>\n"                                               |
173       | :body-number-list-leave-number | t                                                             |
174       |                                |                                                               |
175       | :body-list-checkbox-todo       | "<checkbox type=\"todo\">"                                    |
176       | :body-list-checkbox-todo-end   | "</checkbox (todo)>"                                          |
177       | :body-list-checkbox-done       | "<checkbox type=\"done\">"                                    |
178       | :body-list-checkbox-done-end   | "</checkbox (done)>"                                          |
179       | :body-list-checkbox-half       | "<checkbox type=\"half\">"                                    |
180       | :body-list-checkbox-half-end   | "</checkbox (half)>"                                          |
181       |                                |                                                               |
182       | :body-line-format              | "%s"                                                          |
183       | :body-line-wrap                | 60  ; wrap at 60 chars                                        |
184       |                                |                                                               |
185       | :body-text-prefix              | "<p>\n"                                                       |
186       | :body-text-suffix              | "</p>\n"                                                      |
187       |--------------------------------+---------------------------------------------------------------|
190 * Example Definitions
192 *** Generic HTML Exporter
194     Here's a starting template for making a very basic HTML export.
195     It's not nearly as sophisticated and complete as org-mode's
196     default HTML exporter, but it serves as a good example for how to
197     accomplish a basic export structure:
199 #+begin_src emacs-lisp
200    (org-set-generic-type
201     "really-basic-html" 
202      :file-suffix     ".html"
204      ;; simple html output
205      :file-suffix                   ".html"
206      :key-binding                   ?h
208      :header-prefix             "<body>"
210      :title-format              "<h1>%s</h1>\n\n"
212      :date-export                   t
213      :date-format               "<br /><b>Date:</b> <i>%s</i><br />\n\n"
215      :toc-export                nil
217      :body-header-section-numbers 3
219      :body-section-header-prefix  ("<h1>" "<h2>" "<h3>"
220                                    "<h4>" "<h5>" "<h6>")
221      :body-section-header-format  "%s"
222      :body-section-header-suffix  ("</h1>\n" "</h2>\n" "</h3>\n"
223                                    "</h4>\n" "</h5>\n" "</h6>\n")
225      :body-section-prefix         "<secprefix>\n"
226      :body-section-suffix         "</secsuffix>\n"
227 ;        :body-section-prefix         ("<sec1>\n" "<sec2>\n" "<sec3>\n")
228 ;        :body-section-suffix         ("</sec1>\n" "</sec2>\n" "</sec3>\n")
230      :body-line-export-preformated t
231      :body-line-format             "%s\n"
233      :body-text-prefix "<p>\n"
234      :body-text-suffix "</p>\n"
236      :body-bullet-list-prefix      (?* ?+ ?-)
237 ;        :body-bullet-list-suffix      (?* ?+ ?-)
238      )
239 #+end_src