Skip to content

Commit 77af4e3

Browse files
committed
added rst docs for pypi
1 parent 25b2e37 commit 77af4e3

22 files changed

+1387
-7
lines changed

.eggs/README.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
2+
3+
This directory caches those eggs to prevent repeated downloads.
4+
5+
However, it is safe to delete this directory.
6+
Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
Metadata-Version: 1.1
2+
Name: pypandoc
3+
Version: 1.3.3
4+
Summary: Thin wrapper for pandoc.
5+
Home-page: https://github.com/bebraw/pypandoc
6+
Author: Juho Vepsäläinen
7+
Author-email: [email protected]
8+
License: MIT
9+
Description: # pypandoc
10+
11+
[![Build Status](https://travis-ci.org/bebraw/pypandoc.svg?branch=master)](https://travis-ci.org/bebraw/pypandoc)
12+
[![PyPI version](https://badge.fury.io/py/pypandoc.svg)](https://pypi.python.org/pypi/pypandoc/)
13+
[![conda version](https://anaconda.org/conda-forge/pypandoc/badges/version.svg)](https://anaconda.org/conda-forge/pypandoc/)
14+
15+
pypandoc provides a thin wrapper for [pandoc](http://johnmacfarlane.net/pandoc/), a universal
16+
document converter.
17+
18+
## Installation
19+
20+
pypandoc uses `pandoc`, so it needs an available installation of `pandoc`. For some common cases
21+
(wheels, conda packages), pypandoc already includes `pandoc` (and `pandoc_citeproc`) in it's
22+
prebuilt package.
23+
24+
If `pandoc` is already installed (`pandoc` is in the PATH), `pypandoc` uses the version with the
25+
higher version number and if both are the same, the already installed version. See [Specifying the location of pandoc binaries](#specifying_binaries) for more.
26+
27+
To use `pandoc` filters, you must have the relevant filter installed on your machine.
28+
29+
### Installing via pip
30+
31+
Install via `pip install pypandoc`.
32+
33+
Prebuilt [wheels for Windows and Mac OS X](https://pypi.python.org/pypi/pypandoc/) include
34+
pandoc. If there is no prebuilt binary available, you have to
35+
[install `pandoc` yourself](#installing-pandoc-manually).
36+
37+
If you use Linux and have [your own wheelhouse](http://wheel.readthedocs.org/en/latest/#usage),
38+
you can build a wheel which include `pandoc` with
39+
`python setup.py download_pandoc; python setup.py bdist_wheel`. Be aware that this works only
40+
on 64bit intel systems, as we only download it from the
41+
[official source](https://github.com/jgm/pandoc/releases).
42+
43+
### Installing via conda
44+
45+
`pypandoc` is included in [conda-forge](https://conda-forge.github.io/). The conda packages will
46+
also install the `pandoc` package, so `pandoc` is available in the installation.
47+
48+
Install via `conda install -c conda-forge pypandoc`.
49+
50+
You can also add the channel to your conda config via
51+
`conda config --add channels conda-forge`. This makes it possible to
52+
use `conda install pypandoc` directly and also lets you update via `conda update pypandoc`.
53+
54+
### Installing pandoc
55+
56+
If you don't get `pandoc` installed via a prebuild wheel which includes `pandoc` or via the
57+
conda package dependencies, you need to install `pandoc` by yourself.
58+
59+
#### Installing pandoc via pypandoc
60+
61+
Installing via pypandoc is possible on Windows, Mac OS X or Linux (Intel-based):
62+
63+
```python
64+
# expects a installed pypandoc: pip install pypandoc
65+
from pypandoc.pandoc_download import download_pandoc
66+
# see the documentation how to customize the installation path
67+
# but be aware that you then need to include it in the PATH
68+
download_pandoc()
69+
```
70+
71+
The default install location is included in the search path for `pandoc`, so you
72+
don't need to add it to `PATH`.
73+
74+
#### Installing pandoc manually
75+
76+
Installing manually via the system mechanism is also possible. Such installation mechanism
77+
make `pandoc` available on many more platforms:
78+
79+
- Ubuntu/Debian: `sudo apt-get install pandoc`
80+
- Fedora/Red Hat: `sudo yum install pandoc`
81+
- Arch: `sudo pacman -S pandoc`
82+
- Mac OS X with Homebrew: `brew install pandoc pandoc-citeproc Caskroom/cask/mactex`
83+
- Machine with Haskell: `cabal-install pandoc`
84+
- Windows: There is an installer available
85+
[here](http://johnmacfarlane.net/pandoc/installing.html)
86+
- [FreeBSD port](http://www.freshports.org/textproc/pandoc/)
87+
- Or see http://johnmacfarlane.net/pandoc/installing.html
88+
89+
Be aware that not all install mechanismen put `pandoc` in `PATH`, so you either
90+
have to change `PATH` yourself or set the full path to `pandoc` in
91+
`PYPANDOC_PANDOC`. See the next section for more information.
92+
93+
### <a name="specifying_binaries"></a>Specifying the location of pandoc binaries
94+
95+
You can point to a specific pandoc version by setting the environment variable
96+
`PYPANDOC_PANDOC` to the full path to the pandoc binary
97+
(`PYPANDOC_PANDOC=/home/x/whatever/pandoc` or `PYPANDOC_PANDOC=c:\pandoc\pandoc.exe`).
98+
If this environment variable is set, this is the only place where pandoc is searched for.
99+
100+
In certain cases, e.g. pandoc is installed but a web server with its own user
101+
cannot find the binaries, it is useful to specify the location at runtime:
102+
103+
```python
104+
import os
105+
os.environ.setdefault('PYPANDOC_PANDOC', '/home/x/whatever/pandoc')
106+
```
107+
108+
## Usage
109+
110+
There are two basic ways to use `pypandoc`: with input files or with input
111+
strings.
112+
113+
114+
```python
115+
import pypandoc
116+
117+
# With an input file: it will infer the input format from the filename
118+
output = pypandoc.convert_file('somefile.md', 'rst')
119+
120+
# ...but you can overwrite the format via the `format` argument:
121+
output = pypandoc.convert_file('somefile.txt', 'rst', format='md')
122+
123+
# alternatively you could just pass some string. In this case you need to
124+
# define the input format:
125+
output = pypandoc.convert_text('#some title', 'rst', format='md')
126+
# output == 'some title\r\n==========\r\n\r\n'
127+
```
128+
129+
`convert_text` expects this string to be unicode or utf-8 encoded bytes. `convert_*` will always
130+
return a unicode string.
131+
132+
It's also possible to directly let `pandoc` write the output to a file. This is the only way to
133+
convert to some output formats (e.g. odt, docx, epub, epub3, pdf). In that case `convert_*()` will
134+
return an empty string.
135+
136+
```python
137+
import pypandoc
138+
139+
output = pypandoc.convert_file('somefile.md', 'docx', outputfile="somefile.docx")
140+
assert output == ""
141+
```
142+
143+
In addition to `format`, it is possible to pass `extra_args`.
144+
That makes it possible to access various `pandoc` options easily.
145+
146+
```python
147+
output = pypandoc.convert_text(
148+
'<h1>Primary Heading</h1>',
149+
'md', format='html',
150+
extra_args=['--atx-headers'])
151+
# output == '# Primary Heading\r\n'
152+
output = pypandoc.convert(
153+
'# Primary Heading',
154+
'html', format='md',
155+
extra_args=['--base-header-level=2'])
156+
# output == '<h2 id="primary-heading">Primary Heading</h2>\r\n'
157+
```
158+
pypandoc now supports easy addition of
159+
[pandoc filters](http://johnmacfarlane.net/pandoc/scripting.html).
160+
161+
```python
162+
filters = ['pandoc-citeproc']
163+
pdoc_args = ['--mathjax',
164+
'--smart']
165+
output = pd.convert_file(source=filename,
166+
to='html5',
167+
format='md',
168+
extra_args=pdoc_args,
169+
filters=filters)
170+
```
171+
Please pass any filters in as a list and not as a string.
172+
173+
Please refer to `pandoc -h` and the
174+
[official documentation](http://johnmacfarlane.net/pandoc/README.html) for further details.
175+
176+
> Note: the old way of using `convert(input, output)` is deprecated as in some cases it wasn't
177+
possible to determine whether the input should be used as a filename or as text.
178+
179+
## Dealing with Formatting Arguments
180+
181+
Pandoc supports custom formatting though `-V` parameter. In order to use it through
182+
pypandoc, use code such as this:
183+
184+
```python
185+
output = pypandoc.convert_file('demo.md', 'pdf', outputfile='demo.pdf',
186+
extra_args=['-V', 'geometry:margin=1.5cm'])
187+
```
188+
189+
> Note: it's important to separate `-V` and its argument within a list like that or else
190+
it won't work. This gotcha has to do with the way
191+
[`subprocess.Popen`](https://docs.python.org/2/library/subprocess.html#subprocess.Popen) works.
192+
193+
## Getting Pandoc Version
194+
195+
As it can be useful sometimes to check what Pandoc version is available at your system or which
196+
particular `pandoc` binary is used by `pypandoc`. For that, `pypandoc` provides the following
197+
utility functions. Example:
198+
199+
```
200+
print(pypandoc.get_pandoc_version())
201+
print(pypandoc.get_pandoc_path())
202+
print(pypandoc.get_pandoc_formats())
203+
```
204+
205+
## Related
206+
207+
* [pydocverter](https://github.com/msabramo/pydocverter) is a client for a service called
208+
[Docverter](http://www.docverter.com/), which offers `pandoc` as a service (plus some extra goodies).
209+
* See [pyandoc](http://pypi.python.org/pypi/pyandoc/) for an alternative implementation of a `pandoc`
210+
wrapper from Kenneth Reitz. This one hasn't been active in a while though.
211+
212+
## Contributing
213+
214+
Contributions are welcome. When opening a PR, please keep the following guidelines in mind:
215+
216+
1. Before implementing, please open an issue for discussion.
217+
2. Make sure you have tests for the new logic.
218+
3. Make sure your code passes `flake8 pypandoc/*.py tests.py`
219+
4. Add yourself to contributors at `README.md` unless you are already there. In that case tweak your contributions.
220+
221+
Note that for citeproc tests to pass you'll need to have [pandoc-citeproc](https://github.com/jgm/pandoc-citeproc) installed. If you installed a prebuilt wheel or conda package, it is already included.
222+
223+
## Contributors
224+
225+
* [Valentin Haenel](https://github.com/esc) - String conversion fix
226+
* [Daniel Sanchez](https://github.com/ErunamoJAZZ) - Automatic parsing of input/output formats
227+
* [Thomas G.](https://github.com/coldfix) - Python 3 support
228+
* [Ben Jao Ming](https://github.com/benjaoming) - Fail gracefully if `pandoc` is missing
229+
* [Ross Crawford-d'Heureuse](http://github.com/rosscdh) - Encode input in UTF-8 and add Django
230+
example
231+
* [Michael Chow](https://github.com/machow) - Decode output in UTF-8
232+
* [Janusz Skonieczny](https://github.com/wooyek) - Support Windows newlines and allow encoding to
233+
be specified.
234+
* [gabeos](https://github.com/gabeos) - Fix help parsing
235+
* [Marc Abramowitz](https://github.com/msabramo) - Make `setup.py` fail hard if `pandoc` is
236+
missing, Travis, Dockerfile, PyPI badge, Tox, PEP-8, improved documentation
237+
* [Daniel L.](https://github.com/mcktrtl) - Add `extra_args` example to README
238+
* [Amy Guy](https://github.com/rhiaro) - Exception handling for unicode errors
239+
* [Florian Eßer](https://github.com/flesser) - Allow Markdown extensions in output format
240+
* [Philipp Wendler](https://github.com/PhilippWendler) - Allow Markdown extensions in input format
241+
* [Jan Schulz](https://github.com/JanSchulz) - Handling output to a file, Travis to work on newer version of Pandoc, return code checking, get_pandoc_version. Helped to fix the Travis build, new `convert_*` API
242+
* [Aaron Gonzales](https://github.com/xysmas) - Added better filter handling
243+
* [David Lukes](https://github.com/dlukes) - Enabled input from non-plain-text files and made sure tests clean up template files correctly if they fail
244+
* [valholl](https://github.com/valholl) - Set up licensing information correctly and include examples to distribution version
245+
* [Cyrille Rossant](https://github.com/rossant) - Fixed bug by trimming out stars in the list of `pandoc` formats. Helped to fix the Travis build.
246+
* [Paul Osborne](https://github.com/posborne) - Don't require `pandoc` to install pypandoc.
247+
* [Felix Yan](https://github.com/felixonmars) - Added installation instructions for Arch Linux.
248+
249+
## License
250+
251+
`pypandoc` is available under MIT license. See LICENSE for more details. `pandoc` itself is [available under the GPL2 license](https://github.com/jgm/pandoc/blob/master/COPYING).
252+
253+
Platform: UNKNOWN
254+
Classifier: Development Status :: 4 - Beta
255+
Classifier: Environment :: Console
256+
Classifier: Intended Audience :: Developers
257+
Classifier: Intended Audience :: System Administrators
258+
Classifier: License :: OSI Approved :: MIT License
259+
Classifier: Operating System :: POSIX
260+
Classifier: Programming Language :: Python
261+
Classifier: Topic :: Text Processing
262+
Classifier: Topic :: Text Processing :: Filters
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
LICENSE
2+
MANIFEST.in
3+
README.md
4+
filter_test.md
5+
setup.cfg
6+
setup.py
7+
tests.py
8+
examples/services.py
9+
pypandoc/__init__.py
10+
pypandoc/pandoc_download.py
11+
pypandoc/py3compat.py
12+
pypandoc.egg-info/PKG-INFO
13+
pypandoc.egg-info/SOURCES.txt
14+
pypandoc.egg-info/dependency_links.txt
15+
pypandoc.egg-info/requires.txt
16+
pypandoc.egg-info/top_level.txt
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
setuptools
2+
pip>=8.1.0
3+
wheel>=0.25.0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pypandoc

0 commit comments

Comments
 (0)