retext-project / pymarkups

Wrapper around various text markups, used in ReText
https://pymarkups.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
35 stars 8 forks source link

.. image:: https://github.com/retext-project/pymarkups/workflows/tests/badge.svg :target: https://github.com/retext-project/pymarkups/actions :alt: GitHub Actions status .. image:: https://codecov.io/gh/retext-project/pymarkups/branch/master/graph/badge.svg :target: https://codecov.io/gh/retext-project/pymarkups :alt: Coverage status .. image:: https://readthedocs.org/projects/pymarkups/badge/?version=latest :target: https://pymarkups.readthedocs.io/en/latest/ :alt: ReadTheDocs status

This module provides a wrapper around various text markup languages.

Available by default are Markdown, reStructuredText, Textile and AsciiDoc, but you can easily add your own markups.

Usage example:

.. code:: python

import markups markup = markups.get_markup_for_file_name("myfile.rst") markup.name 'reStructuredText' markup.attributes[markups.common.SYNTAX_DOCUMENTATION] 'https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html' text = """ ... Hello, world! ... ============= ... ... This is an example reStructuredText document. ... """ result = markup.convert(text) result.get_document_title() 'Hello, world!' print(result.get_document_body()) # doctest: +NORMALIZE_WHITESPACE

Hello, world!

This is an example reStructuredText document.

.. _Markdown: https://daringfireball.net/projects/markdown/ .. _reStructuredText: https://docutils.sourceforge.io/rst.html .. Textile: https://en.wikipedia.org/wiki/Textile(markup_language) .. _AsciiDoc: https://asciidoc.org

The release version can be downloaded from PyPI_ or installed using::

pip install Markups

.. _PyPI: https://pypi.org/project/Markups/

The source code is hosted on GitHub_.

.. _GitHub: https://github.com/retext-project/pymarkups

The documentation is available online or can be generated from source by installing Sphinx and running::

python3 -m sphinx docs build/sphinx/html

.. _online: https://pymarkups.readthedocs.io/en/latest/ .. _Sphinx: https://www.sphinx-doc.org/en/master/