{ "info": { "author": "Michal Krenek (Mikos)", "author_email": "m.krenek@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Text Processing :: Markup" ], "description": "ReParser\n========\n\nSimple regex-based lexer/parser for inline markup\n\nRequirements\n------------\n\n- Python 3\n\nUsage\n-----\n\nExample::\n\n import re\n from pprint import pprint\n from reparser import Parser, Token, MatchGroup\n\n boundary_chars = r'\\s`!()\\[\\]{{}};:\\'\".,<>?\u00ab\u00bb\u201c\u201d\u2018\u2019*_~='\n b_left = r'(?:(?<=[' + boundary_chars + r'])|(?<=^))' # Lookbehind\n b_right = r'(?:(?=[' + boundary_chars + r'])|(?=$))' # Lookahead\n\n markdown_start = b_left + r'(?.+?)\\]\\((?P.+?)\\)'\n newline = r'\\n|\\r\\n'\n\n url_proto_regex = re.compile(r'(?i)^[a-z][\\w-]+:/{1,3}')\n\n def markdown(tag):\n \"\"\"Return sequence of start and end regex patterns for simple Markdown tag\"\"\"\n return (markdown_start.format(tag=tag), markdown_end.format(tag=tag))\n\n def url_complete(url):\n \"\"\"If URL doesn't start with protocol, prepend it with http://\"\"\"\n return url if url_proto_regex.search(url) else 'http://' + url\n\n tokens = [\n Token('bi1', *markdown(r'\\*\\*\\*'), is_bold=True, is_italic=True),\n Token('bi2', *markdown(r'___'), is_bold=True, is_italic=True),\n Token('b1', *markdown(r'\\*\\*'), is_bold=True),\n Token('b2', *markdown(r'__'), is_bold=True),\n Token('i1', *markdown(r'\\*'), is_italic=True),\n Token('i2', *markdown(r'_'), is_italic=True),\n Token('pre3', *markdown(r'```'), skip=True),\n Token('pre2', *markdown(r'``'), skip=True),\n Token('pre1', *markdown(r'`'), skip=True),\n Token('s', *markdown(r'~~'), is_strikethrough=True),\n Token('u', *markdown(r'=='), is_underline=True),\n Token('link', markdown_link, text=MatchGroup('link'),\n link_target=MatchGroup('url', func=url_complete)),\n Token('br', newline, text='\\n', segment_type=\"LINE_BREAK\")\n ]\n\n parser = Parser(tokens)\n text = ('Hello **bold** world!\\n'\n 'You can **try *this* awesome** [link](www.eff.org).')\n\n segments = parser.parse(text)\n pprint([(segment.text, segment.params) for segment in segments])\n\nOutput::\n\n [('Hello ', {}),\n ('bold', {'is_bold': True}),\n (' world!', {}),\n ('\\n', {'segment_type': 'LINE_BREAK'}),\n ('You can ', {}),\n ('try ', {'is_bold': True}),\n ('this', {'is_bold': True, 'is_italic': True}),\n (' awesome', {'is_bold': True}),\n (' ', {}),\n ('link', {'link_target': 'http://www.eff.org'}),\n ('.', {})]\n", "description_content_type": null, "docs_url": null, "download_url": null, "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/xmikos/reparser", "keywords": null, "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "ReParser", "package_url": "https://pypi.org/project/ReParser/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ReParser/", "project_urls": { "Homepage": "https://github.com/xmikos/reparser" }, "release_url": "https://pypi.org/project/ReParser/1.4.3/", "requires_dist": null, "requires_python": null, "summary": "Simple regex-based lexer/parser for inline markup", "version": "1.4.3" }, "last_serial": 1708639, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "265bc6f9d7bdbb937a1a2a521a40e6f9", "sha256": "55dfefc1380546f707a2b853a1032fdf12c90bf7e73c527afae9926d5e422553" }, "downloads": -1, "filename": "ReParser-1.0.tar.gz", "has_sig": false, "md5_digest": "265bc6f9d7bdbb937a1a2a521a40e6f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2935, "upload_time": "2015-04-16T15:04:44", "url": "https://files.pythonhosted.org/packages/72/5c/a0eb100e05408a769d333c5146e3e589bdb067bf272036ee537d33affa4f/ReParser-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "ef17f749227af77500f8b86f0e290f4f", "sha256": "10a0f09befa95bd355e2e6eb8e8955c5de7bef890a11ceff0801d06648efc8be" }, "downloads": -1, "filename": "ReParser-1.1.tar.gz", "has_sig": false, "md5_digest": "ef17f749227af77500f8b86f0e290f4f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3185, "upload_time": "2015-04-17T12:49:10", "url": "https://files.pythonhosted.org/packages/8f/a7/7ed67fb25069abac476ba11d9bf787dc04ca4ff7a75b3b3f7e944420a1aa/ReParser-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "ad29aa4f8b221e6bd97f90dd756f04bf", "sha256": "01497427a67a992f1e8dc2f007b9c220b8c533b5cef2bca1808bbde34f8b8c0a" }, "downloads": -1, "filename": "ReParser-1.2.tar.gz", "has_sig": false, "md5_digest": "ad29aa4f8b221e6bd97f90dd756f04bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3481, "upload_time": "2015-04-17T23:54:11", "url": "https://files.pythonhosted.org/packages/6c/2b/ef505c8b200faa979e1457fb6b965f5d42ca14b7f7f24449f42568cb6f88/ReParser-1.2.tar.gz" } ], "1.2.1": [ { "comment_text": "", "digests": { "md5": "6ee8372a115f4e66030a95ca1822f64b", "sha256": "399875db61987dd7fe34a95786a3d47ad7695a316eaf19b6bd4e629154e019b1" }, "downloads": -1, "filename": "ReParser-1.2.1.tar.gz", "has_sig": false, "md5_digest": "6ee8372a115f4e66030a95ca1822f64b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3434, "upload_time": "2015-04-19T15:48:35", "url": "https://files.pythonhosted.org/packages/76/0a/45e23f494bfdf28cebac50e36281d15cc131bec923feac843b7bd7ce8b9a/ReParser-1.2.1.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "946fc280b52ceea2c3a70bcc4b95ad45", "sha256": "2fca3698cfec788a4b44ae7fdfd392c8a88437e5b11d791dd99e77c0fca9ebfc" }, "downloads": -1, "filename": "ReParser-1.3.tar.gz", "has_sig": false, "md5_digest": "946fc280b52ceea2c3a70bcc4b95ad45", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3415, "upload_time": "2015-04-20T15:21:17", "url": "https://files.pythonhosted.org/packages/fc/d9/c1a2259b9b89339a6e266fcc11838ba475ff5e72e5d0cb9051103e82ae96/ReParser-1.3.tar.gz" } ], "1.3.1": [ { "comment_text": "", "digests": { "md5": "18cfb38f38b6d37ecd83cd6947bd506a", "sha256": "66ef665e4d9ef223a0b4ff08b85f960d1da26f4697e29fec264924d982eb787a" }, "downloads": -1, "filename": "ReParser-1.3.1.tar.gz", "has_sig": false, "md5_digest": "18cfb38f38b6d37ecd83cd6947bd506a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3452, "upload_time": "2015-04-20T15:32:51", "url": "https://files.pythonhosted.org/packages/f1/95/caa526a8165e7b7700baedd67ae29b72ccda9b97c1ab8970a8db9a73e7f6/ReParser-1.3.1.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "bd2aea68875337556465fe05a49c0e3b", "sha256": "2fbbbf9cb6296c034fbe7bf76ba40952169ca5f6f4a56db24f428aecdbdf2e9a" }, "downloads": -1, "filename": "ReParser-1.4.tar.gz", "has_sig": false, "md5_digest": "bd2aea68875337556465fe05a49c0e3b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4123, "upload_time": "2015-04-23T01:00:10", "url": "https://files.pythonhosted.org/packages/36/78/fbf175033375715110a6a006cb2092cf61281b0e6388ff84b95b0c90dff9/ReParser-1.4.tar.gz" } ], "1.4.1": [ { "comment_text": "", "digests": { "md5": "dd45a126941d33263962f18d8682965b", "sha256": "34565d9424aeba285d7e2bd075a2c2bf05e0b6a0045a0a948bbdaa92c86c96d8" }, "downloads": -1, "filename": "ReParser-1.4.1.tar.gz", "has_sig": false, "md5_digest": "dd45a126941d33263962f18d8682965b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4166, "upload_time": "2015-04-23T14:06:33", "url": "https://files.pythonhosted.org/packages/e0/70/d23a4896e7477867b644828acda234516aa899c7d2032058848a82784b31/ReParser-1.4.1.tar.gz" } ], "1.4.2": [ { "comment_text": "", "digests": { "md5": "8821c0f4474c3eb3fdd44aa5b93e11bd", "sha256": "8ae07741de71a7ab15e69742b47283708a8f5992edf040e393bdb29818d41165" }, "downloads": -1, "filename": "ReParser-1.4.2.tar.gz", "has_sig": false, "md5_digest": "8821c0f4474c3eb3fdd44aa5b93e11bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4586, "upload_time": "2015-04-26T20:57:13", "url": "https://files.pythonhosted.org/packages/a9/e8/624a90422ee716b56c0e048b82f76d78b7f6a9967e8936d44806e412f30f/ReParser-1.4.2.tar.gz" } ], "1.4.3": [ { "comment_text": "", "digests": { "md5": "37ae35dcc6d7fd025a852161cade0f66", "sha256": "e69caf58a29d6e04723f6a7a456d304b7acfcf413957dafcd90ee49eccc2d15a" }, "downloads": -1, "filename": "ReParser-1.4.3.tar.gz", "has_sig": false, "md5_digest": "37ae35dcc6d7fd025a852161cade0f66", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4560, "upload_time": "2015-09-04T20:16:13", "url": "https://files.pythonhosted.org/packages/a7/eb/8bd06ddaeb3d5963abb0e2e2f14f2fa975b32fafe198254bfb4106ed9415/ReParser-1.4.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "37ae35dcc6d7fd025a852161cade0f66", "sha256": "e69caf58a29d6e04723f6a7a456d304b7acfcf413957dafcd90ee49eccc2d15a" }, "downloads": -1, "filename": "ReParser-1.4.3.tar.gz", "has_sig": false, "md5_digest": "37ae35dcc6d7fd025a852161cade0f66", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4560, "upload_time": "2015-09-04T20:16:13", "url": "https://files.pythonhosted.org/packages/a7/eb/8bd06ddaeb3d5963abb0e2e2f14f2fa975b32fafe198254bfb4106ed9415/ReParser-1.4.3.tar.gz" } ] }