blob: 835a9c5a219cb17e27a4d0e4bee3191e2b27cf26 [file] [log] [blame]
Rich Bennettd504dc82018-05-31 08:40:36 -04001.. This work is licensed under a Creative Commons Attribution 4.0
2.. International License. http://creativecommons.org/licenses/by/4.0
3.. Copyright 2017 AT&T Intellectual Property. All rights reserved.
Rich Bennett5baea462017-09-13 03:19:19 -04004
5.. _converting-to-rst:
6
Spencer Seidelf7100652017-09-06 12:39:15 -04007Converting to RST
8=================
9
10Installing pandoc
11-----------------
12
Rich Bennettd504dc82018-05-31 08:40:36 -040013Pandoc is a powerful document-transformation utility. We'll use it to
14do simple conversions, but it is capable of much more. Visit
15the `pandoc website <http://pandoc.org/installing.html>`_ for
16installation instructions for your platform.
Spencer Seidelf7100652017-09-06 12:39:15 -040017
18Converting
19----------
20
Rich Bennettd504dc82018-05-31 08:40:36 -040021Using a terminal, navigate to the directory containing the documents
22you wish to convert. Next, issue the following command for each file
23you'd like to convert:
Spencer Seidelf7100652017-09-06 12:39:15 -040024
25:code:`pandoc -s --toc -f <from format> -t rst myfile.<from format>`
26
27:code:`-s` tells pandoc to produce a standalone document
28
29:code:`--toc` tells pandoc to produce a table of contents (optional)
30
31:code:`-t` tells pandoc to produce reStructuredText output
32
33:code:`-f` tells pandoc the input format. It should be one of the following:
34
35+--------------------+---------------------------------------------------------------+
36| Format | Description |
37+====================+===============================================================+
38|commonmark | Markdown variant |
39+--------------------+---------------------------------------------------------------+
40|docbook | XML-based markup |
41+--------------------+---------------------------------------------------------------+
42|docx | Microsoft Word |
43+--------------------+---------------------------------------------------------------+
44|epub | Ebook format |
45+--------------------+---------------------------------------------------------------+
46|haddock | Doc format produced by tool used on Haskell code |
47+--------------------+---------------------------------------------------------------+
48|html | HTML |
49+--------------------+---------------------------------------------------------------+
50|json | JSON pandoc AST |
51+--------------------+---------------------------------------------------------------+
52|latex | Older typesetting syntax |
53+--------------------+---------------------------------------------------------------+
54|markdown | Simple formatting syntax meant to produce HTML |
55+--------------------+---------------------------------------------------------------+
56|markdown_github | Github flavored markdown |
57+--------------------+---------------------------------------------------------------+
58|markdown_mmd | Multi-markdown flavored markdown |
59+--------------------+---------------------------------------------------------------+
60|markdown_phpextra | PHP flavored markdown |
61+--------------------+---------------------------------------------------------------+
62|markdown_strict | Markdown with no added pandoc features |
63+--------------------+---------------------------------------------------------------+
64|mediawiki | Popular wiki language |
65+--------------------+---------------------------------------------------------------+
66|native | Pandoc native Haskell |
67+--------------------+---------------------------------------------------------------+
68|odt | Open document text (used by LibreOffice) |
69+--------------------+---------------------------------------------------------------+
70|opml | Outline processor markup language |
71+--------------------+---------------------------------------------------------------+
72|org | Org mode for Emacs |
73+--------------------+---------------------------------------------------------------+
74|rst | reStructuredText |
75+--------------------+---------------------------------------------------------------+
76|t2t | Wiki-like formatting syntax |
77+--------------------+---------------------------------------------------------------+
78|textile | A formatting syntax similar to RST and markdown |
79+--------------------+---------------------------------------------------------------+
80|twiki | Popular wiki formatting syntax |
81+--------------------+---------------------------------------------------------------+
82
83Fixing the converted document
84-----------------------------
85
Rich Bennettd504dc82018-05-31 08:40:36 -040086How much you'll need to fix the converted document depends on which file
87format you're converting from. Here are a couple of things to watch out
88for:
Spencer Seidelf7100652017-09-06 12:39:15 -040089
901. Multi-line titles need to be converted to single line
912. Standalone "**" characters
923. :code:`***bolded***` should be :code:`**bolded**`
934. Mangled tables
94
95Previewing edits
96----------------
97
98Web-based
99~~~~~~~~~
100
Rich Bennettd504dc82018-05-31 08:40:36 -0400101`rst.ninjs.org <http://rst.ninjs.org>`_ has an excellent RST previewing
102tool that highlights RST errors with line numbers.