{"id":19320462,"url":"https://github.com/aluriak/genhtml-markdown","last_synced_at":"2026-02-14T21:02:42.986Z","repository":{"id":33003417,"uuid":"149315554","full_name":"Aluriak/genhtml-markdown","owner":"Aluriak","description":"A markdown extension to write your markdown document in python ","archived":false,"fork":false,"pushed_at":"2023-10-03T22:42:00.000Z","size":2234,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T04:08:15.601Z","etag":null,"topics":["markdown","markdown-plugin","plugin","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Aluriak.png","metadata":{"files":{"readme":"README.mkd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-09-18T16:00:40.000Z","updated_at":"2021-12-25T11:35:08.000Z","dependencies_parsed_at":"2025-10-09T04:08:14.074Z","dependency_job_id":"e3ea8632-7886-4be0-801b-463fdde9038a","html_url":"https://github.com/Aluriak/genhtml-markdown","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/Aluriak/genhtml-markdown","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fgenhtml-markdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fgenhtml-markdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fgenhtml-markdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fgenhtml-markdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Aluriak","download_url":"https://codeload.github.com/Aluriak/genhtml-markdown/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Aluriak%2Fgenhtml-markdown/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29455601,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T15:52:44.973Z","status":"ssl_error","status_checked_at":"2026-02-14T15:52:11.208Z","response_time":53,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["markdown","markdown-plugin","plugin","python"],"created_at":"2024-11-10T01:28:58.839Z","updated_at":"2026-02-14T21:02:42.970Z","avatar_url":"https://github.com/Aluriak.png","language":"Python","readme":"# 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)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluriak%2Fgenhtml-markdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faluriak%2Fgenhtml-markdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluriak%2Fgenhtml-markdown/lists"}