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