{"id":15619611,"url":"https://github.com/ofek/mkpatcher","last_synced_at":"2025-03-29T15:31:06.642Z","repository":{"id":57442193,"uuid":"259100920","full_name":"ofek/mkpatcher","owner":"ofek","description":"Python-Markdown extension allowing arbitrary scripts to modify MkDocs input files","archived":false,"fork":false,"pushed_at":"2020-04-26T19:19:50.000Z","size":9,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-05T13:19:32.122Z","etag":null,"topics":["extension","mkdocs","plugin","python-markdown"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ofek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-04-26T18:13:51.000Z","updated_at":"2020-12-12T04:15:54.000Z","dependencies_parsed_at":"2022-09-26T17:21:05.725Z","dependency_job_id":null,"html_url":"https://github.com/ofek/mkpatcher","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fmkpatcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fmkpatcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fmkpatcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ofek%2Fmkpatcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ofek","download_url":"https://codeload.github.com/ofek/mkpatcher/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246204619,"owners_count":20740345,"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":["extension","mkdocs","plugin","python-markdown"],"created_at":"2024-10-03T08:40:32.192Z","updated_at":"2025-03-29T15:31:06.606Z","avatar_url":"https://github.com/ofek.png","language":"Python","readme":"# mkpatcher\n\n[![PyPI - Status](https://img.shields.io/pypi/status/mkpatcher.svg)](https://pypi.org/project/mkpatcher)\n[![PyPI - Version](https://img.shields.io/pypi/v/mkpatcher.svg)](https://pypi.org/project/mkpatcher)\n[![PyPI - Downloads](https://pepy.tech/badge/mkpatcher)](https://pepy.tech/project/mkpatcher)\n[![License - Apache-2.0 OR MIT](https://img.shields.io/badge/license-Apache--2.0%20OR%20MIT-9400d3.svg)](https://choosealicense.com/licenses)\n[![Code style - black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)\n[![Say Thanks](https://img.shields.io/badge/say-thanks-ff69b4.svg)](https://saythanks.io/to/ofekmeister%40gmail.com)\n\n---\n\n`mkpatcher` is a Python-Markdown extension allowing arbitrary scripts to modify MkDocs input files.\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Raw script](#raw-script)\n  - [Scripts on filesystem](#scripts-on-filesystem)\n- [License](#license)\n\n## Installation\n\n1. `pip install mkpatcher`\n1. Include the extension in your `mkdocs.yml` config file:\n\n    ```yaml\n    ...\n    markdown_extensions:\n      ...\n      - mkpatcher:\n          ...\n    ```\n\n## Usage\n\nThis extension works as a pre-processor and will allow modifying the raw lines of Markdown before any other extension runs.\n\n### Raw script\n\nThe `script` option takes arbitrary Python code and will provide the Markdown lines as a variable named `lines`.\n\nYou can modify the lines directly:\n\n```yaml\n...\nmarkdown_extensions:\n  ...\n  - mkpatcher:\n      script: |\n        lines.extend(('', 'some footer', ''))\n```\n\nor you can shadow the variable:\n\n```yaml\n...\nmarkdown_extensions:\n  ...\n  - mkpatcher:\n      script: |\n        lines = ['entirely', 'new']\n        lines.append('markdown')\n```\n\n### Scripts on filesystem\n\nThe `location` option takes a path to either a single Python file or a directory containing multiple Python files.\nIf the location refers to a directory, the scripts will be loaded and eventually executed in lexicographical order\nbased on file names.\n\n```yaml\n...\nmarkdown_extensions:\n  ...\n  - mkpatcher:\n      location: docs/.scripts\n```\n\nEach script must define a callable object named `patch` that accepts a single parameter which will be the Markdown lines.\n\nYou can modify the lines directly:\n\n```python\ndef patch(lines):\n    lines.extend(('', 'some footer', ''))\n```\n\nor you can return new lines:\n\n```python\ndef patch(lines):\n    new_lines = ['entirely', 'new']\n    new_lines.append('markdown')\n    return new_lines\n```\n\n## License\n\n`mkpatcher` is distributed under the terms of both\n\n- [Apache License, Version 2.0](https://choosealicense.com/licenses/apache-2.0)\n- [MIT License](https://choosealicense.com/licenses/mit)\n\nat your option.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofek%2Fmkpatcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fofek%2Fmkpatcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fofek%2Fmkpatcher/lists"}