abn / pandoc

Pandoc (Python Library)

Home Page:https://boisgera.github.io/pandoc/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pandoc – 🐍 Python Library

Python PyPI version Mkdocs GitHub discussions Downloads GitHub stars

linux macos windows

πŸš€ Getting started

Pandoc – the general markup converter (and Haskell library) written by John MacFarlane – needs to be available. You may follow the official installation instructions or use conda:

$ conda install -c conda-forge pandoc

Then, install the latest stable version of the pandoc Python library with pip:

$ pip install --upgrade pandoc

🌌 Overview

This project brings Pandoc's data model for markdown documents to Python:

$ echo "Hello world!" | python -m pandoc read 
Pandoc(Meta({}), [Para([Str('Hello'), Space(), Str('world!')])])

It can be used to analyze, create and transform documents, in Python :

>>> import pandoc
>>> text = "Hello world!"
>>> doc = pandoc.read(text)
>>> doc
Pandoc(Meta({}), [Para([Str('Hello'), Space(), Str('world!')])])

>>> paragraph = doc[1][0]
>>> paragraph
Para([Str('Hello'), Space(), Str('world!')])
>>> from pandoc.types import Str
>>> paragraph[0][2] = Str('Python!')
>>> text = pandoc.write(doc)
>>> print(text)
Hello Python!

For more information, refer to the πŸ“– documentation.

About

Pandoc (Python Library)

https://boisgera.github.io/pandoc/

License:MIT License


Languages

Language:JavaScript 39.6%Language:Haskell 34.3%Language:Python 26.0%