@@ -0,0 +1,314 @@
2+title: Getting started with pandoc
3+author: John MacFarlane
6+This document is for people who are unfamiliar with command line
7+tools. Command-line experts can go straight to the [User's
8+Guide](README.html) or the pandoc man page.
10+# Step 1: Install pandoc
12+First, install pandoc, following the [instructions for
13+your platform](installing.html).
15+# Step 2: Open a terminal
17+Pandoc is a command-line tool. There is no graphic user interface.
18+So, to use it, you'll need to open a terminal window:
20+- On OS X, the Terminal application can be found in
21+ `/Applications/Utilities`. Open a Finder window and go to
22+ `Applications`, then `Utilities`. Then double click on
23+ `Terminal`. (Or, click the spotlight icon in the upper right
24+ hand corner of your screen and type `Terminal` -- you should
25+ see `Terminal` under `Applications`.)
27+- On Windows, you can use either the classic command prompt or the
28+ more modern PowerShell terminal. If you use Windows in desktop
29+ mode, run the `cmd` or `powershell` command from the Start menu.
30+ If you use the Windows 8 start screen instead, simply type
31+ `cmd` or `powershell`, and then run either the "Command
32+ Prompt" or "Windows Powershell" application. If you are using
33+ `cmd`, type `chcp 65001` before using pandoc, to set the
36+- On Linux, there are many possible configurations, depending on
37+ what desktop environment you're using:
39+ * In Unity, use the search function on the `Dash`, and search
40+ for `Terminal`. Or, use the keyboard shortcut `Ctrl-Alt-T`.
41+ * In Gnome, go to `Applications`, then `Accessories`, and
42+ select `Terminal`, or use `Ctrl-Alt-T`.
43+ * In XFCE, go to `Applications`, then `System`, then `Terminal`,
45+ * In KDE, go to `KMenu`, then `System`, then `Terminal Program (Konsole)`.
47+You should now see a rectangle with a "prompt" (possibly just a symbol
48+like `%`, but probably including more information, such as your
49+username and directory), and a blinking cursor.
51+Let's verify that pandoc is installed. Type
55+and hit enter. You should see a message telling you which version
56+of pandoc is installed, and giving you some additional information.
58+# Step 3: Changing directories
60+First, let's see where we are. Type
68+on Windows, and hit enter. Your terminal should print your current
69+working directory. (Guess what `pwd` stands for?) This should be your
72+Let's navigate now to our `Documents` directory: type
76+and hit enter. Now type
80+(or `echo %cd%` on Windows)
81+again. You should be in the `Documents` subdirectory of your home
82+directory. To go back to your home directory, you could type
86+The `..` means "one level up."
88+Go back to your `Documents` directory if you're not there already.
89+Let's try creating a subdirectory called `pandoc-test`:
93+Now change to the `pandoc-test` directory:
97+If the prompt doesn't tell you what directory you're in, you can
98+confirm that you're there by doing
102+(or `echo %cd%`) again.
104+OK, that's all you need to know for now about using the terminal.
105+But here's a secret that will save you a lot of typing. You can
106+always type the up-arrow key to go back through your history
107+of commands. So if you want to use a command you typed earlier,
108+you don't need to type it again: just use up-arrow until it comes
109+up. Try this. (You can use down-arrow as well, to go the other
110+direction.) Once you have the command, you can also use the
111+left and right arrows and the backspace/delete key to edit it.
113+Most terminals also support tab completion of directories and
114+filenames. To try this, let's first go back up to our `Documents`
123+and hit the tab key instead of enter. Your terminal should fill
124+in the rest (`test`), and then you can hit enter.
128+ - `pwd` (or `echo %cd%` on Windows)
129+ to see what the current working directory is.
130+ - `cd foo` to change to the `foo` subdirectory of your working
132+ - `cd ..` to move up to the parent of the working directory.
133+ - `mkdir foo` to create a subdirectory called `foo` in the
135+ - up-arrow to go back through your command history.
136+ - tab to complete directories and file names.
138+# Step 4: Using pandoc as a filter
144+and hit enter. You should see the cursor just sitting there, waiting
145+for you to type something. Type this:
152+When you're finished (the cursor should be at the beginning of the line),
153+type `Ctrl-D` on OS X or Linux, or `Ctrl-Z` followed
154+by `Enter` on Windows. You should now see your text converted to HTML!
156+ <p>Hello <em>pandoc</em>!</p>
162+What just happened? When pandoc is invoked without specifying any
163+input files, it operates as a "filter," taking input from the
164+terminal and sending its output back to the terminal. You can use
165+this feature to play around with pandoc.
167+By default, input is interpreted as pandoc markdown, and output is
168+HTML. But we can change that. Let's try converting *from* HTML
171+ pandoc -f html -t markdown
175+ <p>Hello <em>pandoc</em>!</p>
177+and hit `Ctrl-D` (or `Ctrl-Z` followed by `Enter` on Windows).
182+Now try converting something from markdown to LaTeX. What command
183+do you think you should use?
185+# Step 5: Text editor basics
187+You'll probably want to use pandoc to convert a file, not to read
188+text from the terminal. That's easy, but first we need to create
189+a text file in our `pandoc-test` subdirectory.
191+**Important:** To create a text file, you'll need to use a text
192+editor, *not* a word processor like Microsoft Word. On Windows, you
193+can use Notepad (in `Accessories`). On OS X, you can use
194+`TextEdit` (in `Applications`). On Linux, different platforms come
195+with different text editors: Gnome has `GEdit`, and KDE has `Kate`.
197+Start up your text editor. Type the following:
201+ This is a test of *pandoc*.
206+Now save your file as `test1.md` in the directory
207+`Documents/pandoc-test`.
209+Note: If you use plain text a lot, you'll want a better editor than
210+`Notepad` or `TextEdit`. You might want to look at
211+[Sublime Text](http://www.sublimetext.com/) or (if you're willing
212+to put in some time learning an unfamiliar interface)
213+[Vim](http://www.vim.org) or [Emacs](http://www.gnu.org/software/emacs).
215+# Step 6: Converting a file
217+Go back to your terminal. We should still be in the
218+`Documents/pandoc-test` directory. Verify that with `pwd`.
224+(or `dir` if you're on Windows).
225+This will list the files in the current directory. You should see
226+the file you created, `test1.md`.
228+To convert it to HTML, use this command:
230+ pandoc test1.md -f markdown -t html -s -o test1.html
232+The filename `test1.md` tells pandoc which file to convert.
233+The `-s` option says to create a "standalone" file, with a header
234+and footer, not just a fragment. And the `-o test1.html` says
235+to put the output in the file `test1.html`. Note that we could
236+have omitted `-f markdown` and `-t html`, since the default
237+is to convert from markdown to HTML, but it doesn't hurt to
240+Check that the file was created by typing `ls` again. You
241+should see `test1.html`. Now open this in a browser. On OS X,
250+You should see a browser window with your document.
252+To create a LaTeX document, you just need to change the command
255+ pandoc test1.md -f markdown -t latex -s -o test1.tex
257+Try opening `test1.tex` in your text editor.
259+Pandoc can often figure out the input and output formats from
260+the filename extensions. So, you could have just used:
262+ pandoc test1.md -s -o test1.tex
264+Pandoc knows you're trying to create a LaTeX document, because of the
267+Now try creating a Word document (with extension `docx`).
269+If you want to create a PDF, you'll need to have LaTeX installed.
270+(See [MacTeX](http://tug.org/mactex/) on OS X,
271+[MiKTeX](http://miktex.org) on Windows, or install the texlive
272+package in linux.) Then do
274+ pandoc test1.md -s -o test1.pdf
276+# Step 7: Command-line options
278+You now know the basics. Pandoc has a lot of options. At this point
279+you can start to learn more about them by reading the
280+[User's Guide](README.html).
282+Here's an example. The `--mathml` option causes pandoc to
283+convert TeX math into MathML. Type
287+then enter this text, followed by `Ctrl-D` (`Ctrl-Z` followed by
292+Now try the same thing without `--mathml`. See the difference
295+If you forget an option, or forget which formats are supported, you
300+to get a list of all the supported options.
302+On OS X or Linux systems, you can also do
306+to get the pandoc manual page. All of this information is also
309+If you get stuck, you can always ask questions on the
310+[pandoc-discuss](http://groups.google.com/group/pandoc-discuss)
311+mailing list. But be sure to check the [FAQs](faqs.html) first,
312+and search through the mailing list to see if your question has
313+been answered before.