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