{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup" ], "description": "pedantmark\n==========\n\n Only two maybes I've thought of: Strict Markdown or Pedantic Markdown. \"Strict\" still doesn't seem right.\n\n -- `John Gruber`_\n\n.. _`John Gruber`: https://twitter.com/gruber/status/507615356295200770)\n\nOk, let's call it **pedantmark**.\n\n**pedantmark** is (not only) a python binding for the GitHub's fork of CommonMark (cmark).\nIt has been enhanced by me (Hsiaoming Yang) to support custom renderers.\n\n.. note::\n If you are a C pro, please help me to improve the C code in this repo.\n\nInstall\n-------\n\n**pedantmark** is available in Python 2.7 and 3.5+ for Linux and Mac,\nPython 3.5+ for Windows. Wheels are built by multibuild_.\n\nInstall wheels by pip::\n\n $ pip install pedantmark\n\n.. _multibuild: https://github.com/matthew-brett/multibuild\n\n\nStandard Usage\n--------------\n\nThe C source code has serval built-in renderers. The simplest interface is\n``pedantmark.html(text, options)``, which will render text into HTML.\n\n.. code-block:: python\n\n import pedantmark\n\n text = '...'\n html = pedantmark.html(text, options=[pedantmark.OPT_VALIDATE_UTF8])\n\nThe function ``pedantmark.html()`` accepts no extensions, but you can add\nextensions via ``pedantmark.markdown()``:\n\n.. code-block:: python\n\n import pedantmark\n\n text = '...'\n html = pedantmark.markdown(\n text,\n options=[pedantmark.OPT_VALIDATE_UTF8],\n extensions=['strikethrough', 'autolink', 'table'],\n renderer='html',\n )\n\nAvailable extensions: ``table``, ``autolink``, ``tagfilter``, ``strikethrough``.\nYou can enable them all with a shortcut::\n\n pedantmark.markdown(..., extensions=pedantmark.EXTENSIONS)\n\nAvailable renderers: ``html``, ``xml``, ``man``, ``commonmark``, ``plaintext``,\nand ``latex``.\n\nCustom Renderer\n---------------\n\nBesides the native renderers, **pedantmark** has provided you a custom renderer,\nwhich you can customize the output yourself. Here is an example of pygments code\nhighlighting integration:\n\n.. code-block:: python\n\n from pedantmark import HTMLRenderer, markdown\n from pygments import highlight\n from pygments.lexers import get_lexer_by_name\n from pygments.formatters import html\n\n class MyRenderer(HTMLRenderer):\n def code_block(self, code, lang):\n if lang:\n # everything is in bytes\n lang = lang.decode('utf-8')\n code = code.decode('utf-8')\n lexer = get_lexer_by_name(lang, stripall=True)\n formatter = html.HtmlFormatter()\n output = highlight(code, lexer, formatter)\n # return bytes\n return output.encode('utf-8')\n return super(MyRenderer, self).code_block(code, lang)\n\n text = '...'\n markdown(text, renderer=MyRenderer())\n\nThe default ``HTMLRenderer`` has a built-in hook for code highlight, you don't need\nto subclass at all:\n\n.. code-block:: python\n\n def add_code_highlight(code, lang):\n lang = lang.decode('utf-8')\n code = code.decode('utf-8')\n lexer = get_lexer_by_name(lang, stripall=True)\n formatter = html.HtmlFormatter()\n output = highlight(code, lexer, formatter)\n return output.encode('utf-8')\n\n text = '...'\n markdown(text, renderer=HTMLRenderer(highlight=add_code_highlight))\n\nAuthor & License\n----------------\n\nThis library is created by Hsiaming Yang, licensed under BSD.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lepture/pedantmark", "keywords": "", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "pedantmark", "package_url": "https://pypi.org/project/pedantmark/", "platform": "", "project_url": "https://pypi.org/project/pedantmark/", "project_urls": { "Homepage": "https://github.com/lepture/pedantmark" }, "release_url": "https://pypi.org/project/pedantmark/0.1/", "requires_dist": [ "cffi (>=1.11.0)" ], "requires_python": "", "summary": "Python binding of GitHub cmark with extensions and renderers", "version": "0.1" }, "last_serial": 4529154, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "19d10cabfc8e7feb15822311fd542513", "sha256": "f818e21b6dff7d04f79aa9d6b2d5c9d0dde3edf3b9fd9b39ddcc2b2ff740367f" }, "downloads": -1, "filename": "pedantmark-0.1-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "19d10cabfc8e7feb15822311fd542513", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 140369, "upload_time": "2018-11-26T10:46:03", "url": "https://files.pythonhosted.org/packages/4c/82/d2663ffbdd842008ee469ad9ae914e2f0bab26a3bc65006cc1880da042f4/pedantmark-0.1-cp36-cp36m-macosx_10_13_x86_64.whl" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "19d10cabfc8e7feb15822311fd542513", "sha256": "f818e21b6dff7d04f79aa9d6b2d5c9d0dde3edf3b9fd9b39ddcc2b2ff740367f" }, "downloads": -1, "filename": "pedantmark-0.1-cp36-cp36m-macosx_10_13_x86_64.whl", "has_sig": false, "md5_digest": "19d10cabfc8e7feb15822311fd542513", "packagetype": "bdist_wheel", "python_version": "cp36", "requires_python": null, "size": 140369, "upload_time": "2018-11-26T10:46:03", "url": "https://files.pythonhosted.org/packages/4c/82/d2663ffbdd842008ee469ad9ae914e2f0bab26a3bc65006cc1880da042f4/pedantmark-0.1-cp36-cp36m-macosx_10_13_x86_64.whl" } ] }