====== Exporting ======

**Zim** will be able to export content to various formats but at the moment only exporting to (simple) Html is supported.

To open op the export dialog in **zim** use the "//File//->//Export//" menu item. This dialog asks for a number of input fields before you can start exporting.

To select the **Pages** you want to export you can check "All" if you want to export the whole tree, or you can check "Page" if you want to export a selection.

When you make a selection you can enter one or more pages or namespaces in the text entry field separated by spaces. namespaces always end with a ":", pages do not. The **Recursive** option automatically adds the coresponding namespace for each page when set.

The **Format** is fixed on "Html" for now. Later other options will be added here.

The **Template** field asks you to select a template file (see below). When you select "''other...''" in the combo box you can fill in a file name in the text input field below the combo box.

Finally an **Output dir** is required, this is the directory name where you want to save the exported pages. This can be a non-existing directory. You can use "''~/''" to refer to you home directory here.

The **Media** section allows you to choose what you want to do with linked files and images. If you use "//Relative linked//" the links are not changed and remain as the are in the original repository. If you choose "//Absolute linked//" all links to files and images are made absolute paths. The third option "//Copy media//" will copy all linked files and images to the output directory, even files that are not inside the directory of the original repository. This option can be used when for example you export html to a web root.

===== Templates =====

==== Available templates ====

=== "Default" ===
This is a simple template intended as a base for custom styles. It has an inline style definition that is intended to match the (default) look of zim.

=== "Presentation" ===
Template with a little more color than "Default". It is intended to convert a set of pages in an online presentation quickly. Simple javascript included for some basic keybindings:

	Enter             next page
	Spacebar          next page
	backspace         previous page

=== "Print" ===
This is a plain template intended for printing pages. It is use by the "Print to Browser" [[plugins|plugin]].

=== "SlideShow (S5)" ===
Template based on S5. S5 is "A Simple Standards-Based Slide Show System", which mean a slide show system completely written in html and javascript. Therefor these slide shows can be presented using a browser and be put on a website. See [[http://meyerweb.com/eric/tools/s5/|the S5 website]] for more information.

Note that in order to use the output from this template you need to download the S5 package and copy the "ui" directory from the package to the same directory where you export your slideshow to.

==== Source ====
The export code only produces the tags that represent the content of the page. It does not add elements like a <head> section. Templates are used to create complete Html pages. A few standard templates are packaged with **zim**, but you can also make your own.

Templates are located in ''/usr/share/zim/templates/'' and ''~/.local/share/zim/templates'' by default. You can add templates you use more often there.

Template syntax:

	[% var %]					# interpolates a variable

	[% IF var %] ... [% END %]	# conditionals
	[% IF var %]
	...
	[% ELSE %]
	...
	[% END %]

	[% FOREACH name = var ]		# loop
	... [% name %] ...
	[% END %]

Available variables:

	page.name
	page.namespace
	page.title
	page.heading
	page.body
	page.links		# list of vars with a .file and a .name subvar
	page.backlinks		# "" idem ""
	prev.name
	prev.file
	next.name
	next.file
	repository.root
	zim.version

The "Title" field contains either the first heading in the page or the page name. If the first header is used, this header is removed from the "Body" field.

===== Exporting from the commandline =====

Try something like:

	$ zim --export \
	  format=html,template=./foo.html,dir=./html,media=copy \
	  ~/docs/zim :notes:

This should export the ''notes:'' namespace from the repository in "''~/docs/" ''to Html using template "''foo.html"''. The "root" of the export string is the directory used for the exporter output.

You can also add the option ''recurs=0'' if you don't want to export sub-namespaces. This option defaults to 1.

===== TODO =====
* Set an header offset, for example if offset is 2 all head1 => head2, all head2 => head3 etc. This is useful when the template also contains headers. 
* Have the option to compile a namespace into one big page.
