{ "info": { "author": "Lucas Bourneuf", "author_email": "lucas.bourneuf@laposte.net", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# genhtml-markdown\n[Python-Markdown](http://pythonhosted.org/Markdown/) plugin allowing to build HTML from inline python source.\n\nDirect applications includes [charts and other plots](https://plot.ly/python/) in markdown documents, and tooling for [blogging](https://blog.getpelican.com/).\n\n pip install genhtml-markdown\n\nSee the [compiled examples and their sources](examples/) for an introductory tour, the [Makefile](Makefile) for the process, or look at next section:\n\n\n## Basic example with plotly\nLet's take an [offline scatter plot example](https://plot.ly/python/getting-started/#initialization-for-offline-plotting), modified to print the generated HTML :\n\n```python\nimport plotly.offline\nimport plotly.graph_objs as go\n\ndata = go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])\nlayout = go.Layout(title=\"hello world\")\n\nfigure = go.Figure(data=[data], layout=layout)\nprint(offline.plot(figure, output_type='div'))\n```\n\nYou could want to include it in your article. With genhtml-markdown extension, it's easy:\n\n ```genhtml\n import plotly.offline\n import plotly.graph_objs as go\n\n data = go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])\n layout = go.Layout(title=\"hello world\")\n\n figure = go.Figure(data=[data], layout=layout)\n print(offline.plot(figure, output_type='div'))\n ```\n\nYou think it's verbose ? I do too. That's the reason we have *headers* and *footers*, patches of python that will be put respectively *before* and *after* our specific code. By default, the header is full of imports, including the plotly ones. And the two last lines are provided by the *plot* footer. So, here is our final code:\n\n ```genhtml footer=plot\n data = go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])\n layout = go.Layout(title=\"hello world\")\n ```\n\nImports and offline plotting boilerplate code will be added by headers/footers, the total code will be ran, and finally the output will be included in place as an interactive plot/chart.\n\n\n## Features\n\n### Ready-to-use headers and footers\nYou can see the full list of [headers](headers/) and [footers](footers/) in their respective directories. You can also pass `headers_dir` and `footers_dir` [parameters for the extensions](https://python-markdown.github.io/cli/#using-extensions) in order to provide your own !\n\nFor instance, with the parameter `-c config.json` added to `python -m markdown` call, you can feed markdown with the following parameters:\n\n```json\n{\n\t\"genhtml\": {\n\t\t\"headers_dir\": \"alt-headers\"\n\t}\n}\n```\n\nIndicating that genhtml will also look in the `alt-headers/` directory for headers.\nOptions can also be set when calling [markdown module programatically](https://python-markdown.github.io/extensions/api/#configsettings) with something like `markdown.Markdown(extensions=[GenHTMLMarkdownExtension(headers_dir='~/my-headers-dir'])`.\n\nFinally, note that the [default header](headers/default.py) provides a lot of imports.\n\n### Generate and show raw images\nAs shown in [images example](examples/images.mkd),\nit is quite easy to build and show an image inline :\n\n ```genhtml format=png footer=png-image\n from PIL import Image\n image = Image.new('RGB', (60, 30), color='green')\n ```\n\nThe `format=png` options tells that the printed data is (base64-encoded) raw png data,\nand the [*png-image* footer](genhtml/footers/png-image.py) reads something like:\n\n```python\nimport io\nimport base64\nwith io.BytesIO() as output:\n image.save(output, format='png')\n print(base64.b64encode(output.getvalue()).decode(), end='')\n```\n\nOther formats are `jpg` and `svg`, allowing you to [bring gizeh to your markdown](https://github.com/Zulko/gizeh).\n\n\n### Graphs\nUsing the previous feature, it becomes possible to draw graphs from their networkx definition, as shown in [the related example](examples/networkx_and_dot.mkd).\n\nUsing the *dot-png* footer, you can just build your graph and print it in no time:\n\n ```genhtml format=png footer=dot-png\n graph = nx.fast_gnp_random_graph(10, 0.5)\n # draw the first one in beige\n graph.nodes[1]['style'] = 'filled'\n graph.nodes[1]['fillcolor'] = 'beige'\n ```\n\n### Show sources, and other code manipulations\nSee the related [example](examples/arbitrary-python.mkd).\n\n### Nested code generation\nIs fully supported. See [pyception example](examples/pyception.mkd).\n\n\n### Use static data\nYou have in the code access to active directory.\nFor instance, if using [pelican](https://blog.getpelican.com/), you can read all your blog articles in few lines:\n\n ```genhtml\n import glob\n print('Follows a list of published articles:')\n for article in glob.glob('content/articles/*.mkd'):\n if any(line.strip() == 'status: published' for line in open(article)):\n print(f'- {article}')\n ```\n\nFollowing this logic, if you are using recurrent CSV data, you could put it in a dedicated directory,\nand access it easily from all your integrated python code.\n\n### Global environment\nAn environment is shared among codes in the same document.\nAs shown in [related example](examples/env-management.mkd), you can access it with the flag `global-env=true`.\n\n## Other features\n- headers/footers for [biseau](https://gitlab.inria.fr/lbourneu/biseau), allowing [ASP](https://lucas.bourneuf.net/blog/asp-tuto.html) in markdown to draw graphs.\n\n## Incoming features\n- access to all markdown article from python (allowing to access the article itself)", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/aluriak/genhtml-markdown", "keywords": "Markdown,plot,include,plugin,extension", "license": "GPL", "maintainer": "", "maintainer_email": "", "name": "genhtml-markdown", "package_url": "https://pypi.org/project/genhtml-markdown/", "platform": "", "project_url": "https://pypi.org/project/genhtml-markdown/", "project_urls": { "Homepage": "https://github.com/aluriak/genhtml-markdown" }, "release_url": "https://pypi.org/project/genhtml-markdown/1.0.9/", "requires_dist": null, "requires_python": "", "summary": "bring python to markdown to generate HTML inline", "version": "1.0.9" }, "last_serial": 4450087, "releases": { "1.0.7": [ { "comment_text": "", "digests": { "md5": "b3117f8844c5d9d42b7a2e1a293752dc", "sha256": "7e3ffd11e66617e750a76e5042cb15b0b822d21de1feb50b589bf1a8ace08c60" }, "downloads": -1, "filename": "genhtml_markdown-1.0.7-py3-none-any.whl", "has_sig": false, "md5_digest": "b3117f8844c5d9d42b7a2e1a293752dc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8019, "upload_time": "2018-09-20T19:08:05", "url": "https://files.pythonhosted.org/packages/e6/3e/38e93c44ececac913ee9494e1e58d341124584c3fa556bf2cdf430065a86/genhtml_markdown-1.0.7-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d1a3d3a3cd302572a4ee4940bcdcfc1e", "sha256": "f7d976742b4253bbad5a7cc6ae30f9ef0d6a251c33da171c3b19b6ade765e3c1" }, "downloads": -1, "filename": "genhtml-markdown-1.0.7.tar.gz", "has_sig": false, "md5_digest": "d1a3d3a3cd302572a4ee4940bcdcfc1e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6959, "upload_time": "2018-09-20T19:08:04", "url": "https://files.pythonhosted.org/packages/22/7b/fdbd8b6e6fe20d7dc76073a5e2f11c83db3e9976d07000a2de720988db83/genhtml-markdown-1.0.7.tar.gz" } ], "1.0.8": [ { "comment_text": "", "digests": { "md5": "7575cbc15e13e2b492299dd2ac73c02b", "sha256": "e57929cd6afdf0da7717a0967154ef919b894991a21f9392c40a48a10c0331ce" }, "downloads": -1, "filename": "genhtml_markdown-1.0.8-py3-none-any.whl", "has_sig": false, "md5_digest": "7575cbc15e13e2b492299dd2ac73c02b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9216, "upload_time": "2018-09-27T18:32:55", "url": "https://files.pythonhosted.org/packages/bd/67/32b0310c01ece82198666fd3244ff7da91469a25d6da99c5562a6561435c/genhtml_markdown-1.0.8-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "35b830073aa9c42e6edbcab023b4867d", "sha256": "b2d10439f65761ec39455472d1db31915776c592da965f894b2279b70f8ecc28" }, "downloads": -1, "filename": "genhtml-markdown-1.0.8.tar.gz", "has_sig": false, "md5_digest": "35b830073aa9c42e6edbcab023b4867d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8608, "upload_time": "2018-09-27T18:32:54", "url": "https://files.pythonhosted.org/packages/c6/ed/4365beda454c207a7534c6aa21c0f730a0bcf02724378c809e5460fe0cc7/genhtml-markdown-1.0.8.tar.gz" } ], "1.0.9": [ { "comment_text": "", "digests": { "md5": "70c9bcd4049a5d585e07efe5d89c58b3", "sha256": "097b7231260417b3588926f33782f6495d1c0e23e0545d6c784f404dbde1e04d" }, "downloads": -1, "filename": "genhtml_markdown-1.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "70c9bcd4049a5d585e07efe5d89c58b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10676, "upload_time": "2018-11-04T16:58:01", "url": "https://files.pythonhosted.org/packages/94/e2/e407935376fc384f648cd7c1052a6594e06258d805ddd98f12a6a7b2a070/genhtml_markdown-1.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "317a0d6140e52ea802b8c1599ab2e389", "sha256": "48f52c7bb4e2907a7546f4484520049d6dacd283ddd14660a6d247ff1898d9e7" }, "downloads": -1, "filename": "genhtml-markdown-1.0.9.tar.gz", "has_sig": false, "md5_digest": "317a0d6140e52ea802b8c1599ab2e389", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8624, "upload_time": "2018-11-04T16:57:59", "url": "https://files.pythonhosted.org/packages/14/7d/8ea3cef809c61625b76b65bc58ad7bc5f803b39b23465f7360e978ce8295/genhtml-markdown-1.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "70c9bcd4049a5d585e07efe5d89c58b3", "sha256": "097b7231260417b3588926f33782f6495d1c0e23e0545d6c784f404dbde1e04d" }, "downloads": -1, "filename": "genhtml_markdown-1.0.9-py3-none-any.whl", "has_sig": false, "md5_digest": "70c9bcd4049a5d585e07efe5d89c58b3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10676, "upload_time": "2018-11-04T16:58:01", "url": "https://files.pythonhosted.org/packages/94/e2/e407935376fc384f648cd7c1052a6594e06258d805ddd98f12a6a7b2a070/genhtml_markdown-1.0.9-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "317a0d6140e52ea802b8c1599ab2e389", "sha256": "48f52c7bb4e2907a7546f4484520049d6dacd283ddd14660a6d247ff1898d9e7" }, "downloads": -1, "filename": "genhtml-markdown-1.0.9.tar.gz", "has_sig": false, "md5_digest": "317a0d6140e52ea802b8c1599ab2e389", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8624, "upload_time": "2018-11-04T16:57:59", "url": "https://files.pythonhosted.org/packages/14/7d/8ea3cef809c61625b76b65bc58ad7bc5f803b39b23465f7360e978ce8295/genhtml-markdown-1.0.9.tar.gz" } ] }