{"id":13472471,"url":"https://github.com/pawamoy/markdown-exec","last_synced_at":"2025-05-15T19:07:06.379Z","repository":{"id":60357552,"uuid":"458362417","full_name":"pawamoy/markdown-exec","owner":"pawamoy","description":"Utilities to execute code blocks in Markdown files.","archived":false,"fork":false,"pushed_at":"2025-03-27T13:45:17.000Z","size":2230,"stargazers_count":148,"open_issues_count":19,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-10T09:45:41.270Z","etag":null,"topics":["literate-programming","markdown","python-markdown"],"latest_commit_sha":null,"homepage":"https://pawamoy.github.io/markdown-exec","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pawamoy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"pawamoy","polar":"pawamoy"}},"created_at":"2022-02-11T22:48:50.000Z","updated_at":"2025-05-06T01:43:22.000Z","dependencies_parsed_at":"2023-02-17T11:45:17.331Z","dependency_job_id":"6d23ede3-5bf6-4b38-a0e1-5c44d0bc5fab","html_url":"https://github.com/pawamoy/markdown-exec","commit_stats":{"total_commits":221,"total_committers":3,"mean_commits":73.66666666666667,"dds":"0.23076923076923073","last_synced_commit":"57ee30d148a02fabb75d1ad8c8f730f198a15219"},"previous_names":[],"tags_count":36,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawamoy%2Fmarkdown-exec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawamoy%2Fmarkdown-exec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawamoy%2Fmarkdown-exec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pawamoy%2Fmarkdown-exec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pawamoy","download_url":"https://codeload.github.com/pawamoy/markdown-exec/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254404356,"owners_count":22065641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["literate-programming","markdown","python-markdown"],"created_at":"2024-07-31T16:00:54.915Z","updated_at":"2025-05-15T19:07:06.355Z","avatar_url":"https://github.com/pawamoy.png","language":"Python","readme":"# Markdown Exec\n\n[![ci](https://github.com/pawamoy/markdown-exec/workflows/ci/badge.svg)](https://github.com/pawamoy/markdown-exec/actions?query=workflow%3Aci)\n[![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://pawamoy.github.io/markdown-exec/)\n[![pypi version](https://img.shields.io/pypi/v/markdown-exec.svg)](https://pypi.org/project/markdown-exec/)\n[![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#markdown-exec:gitter.im)\n\nUtilities to execute code blocks in Markdown files.\n\nFor example, you write a Python code block that computes some HTML,\nand this HTML is injected in place of the code block.\n\n## Installation\n\n```bash\npip install \"markdown-exec[ansi]\"\n```\n\nThe `ansi` extra provides the necessary bits (`pygments-ansi-color` and a CSS file)\nto render ANSI colors in HTML code blocks. The CSS file is automatically added\nto MkDocs' `extra_css` when Markdown Exec is activated via `plugins` (see below).\n\n## Configuration\n\nThis extension relies on the\n[SuperFences](https://facelessuser.github.io/pymdown-extensions/extensions/superfences/)\nextension of\n[PyMdown Extensions](https://facelessuser.github.io/pymdown-extensions/).\n\nTo allow execution of code blocks,\nconfigure a custom fence from Python:\n\n```python\nfrom markdown import Markdown\nfrom markdown_exec import formatter, validator\n\nMarkdown(\n    extensions=[\"pymdownx.superfences\"],\n    extension_configs={\n        \"pymdownx.superfences\": {\n            \"custom_fences\": [\n                {\n                    \"name\": \"python\",\n                    \"class\": \"python\",\n                    \"validator\": validator,\n                    \"format\": formatter,\n                }\n                # ...one fence for each language we support:\n                # bash, console, md, markdown, py, python, pycon, sh, tree\n            ]\n        }\n    }\n)\n```\n\n...or in MkDocs configuration file, as a Markdown extension:\n\n```yaml\n# mkdocs.yml\nmarkdown_extensions:\n- pymdownx.superfences:\n    custom_fences:\n    - name: python\n      class: python\n      validator: !!python/name:markdown_exec.validator\n      format: !!python/name:markdown_exec.formatter\n    # ...one fence for each language we support:\n    # bash, console, md, markdown, py, python, pycon, sh, tree\n```\n\n...or in MkDocs configuration file, as a plugin:\n\n```yaml\n# mkdocs.yml\nplugins:\n- search\n- markdown-exec\n\n# SuperFences must still be enabled!\nmarkdown_extensions:\n- pymdownx.superfences\n```\n\nWe do recommend enabling Markdown Exec with the MkDocs plugin\nif you are using MkDocs: it will take care of adding relevant\nassets (CSS/JS) to the final site when needed. \n\n## Usage\n\nYou are now able to execute code blocks instead of displaying them:\n\n````md\n```python exec=\"on\"\nprint(\"Hello Markdown!\")\n```\n````\n\nThe `exec` option will be true for every possible value except `0`, `no`, `off` and `false` (case insensitive).\n\nBelow you can see an example of running a bash script that is expected to\nreturn a non-zero exit code:\n\n````md\n```bash exec=\"1\" source=\"tabbed-left\" returncode=\"2\"\ngrep extra_css README.md \u0026\u0026 exit 2\n```\n````\n\nSee [usage](https://pawamoy.github.io/markdown-exec/usage/) for more details,\nand the [gallery](https://pawamoy.github.io/markdown-exec/gallery/) for more examples!\n","funding_links":["https://github.com/sponsors/pawamoy","https://polar.sh/pawamoy"],"categories":["Python","markdown"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawamoy%2Fmarkdown-exec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpawamoy%2Fmarkdown-exec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpawamoy%2Fmarkdown-exec/lists"}