Metadata-Version: 2.1
Name: mdreftidy
Version: 0.3.1
Summary: CLI to tidy ({renumber,move-to-bottom,sort,clean}) up {image,link} references for markdown.
Author-email: AYF <realazthat@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Azriel Fasten.
        
        Permission is hereby granted, free of charge, to any person obtaining a copy of
        this software and associated documentation files (the "Software"), to deal in
        the Software without restriction, including without limitation the rights to
        use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
        the Software, and to permit persons to whom the Software is furnished to do so,
        subject to the following conditions:
        
        The above copyright notice and this permission notice (including the next
        paragraph) shall be included in all copies or substantial portions of the
        Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
        FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
        COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
        IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
        CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
        
Project-URL: Homepage, https://github.com/realazthat/mdreftidy
Project-URL: Documentation, https://github.com/realazthat/mdreftidy
Project-URL: Repository, https://github.com/realazthat/mdreftidy
Keywords: github,markdown,readme,documentation,preprocessor,documentation-tool,readme-md
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: colorama<1,>=0.4
Requires-Dist: importlib-metadata; python_version < "3.8"
Requires-Dist: mistletoe<2,>=1
Requires-Dist: pyyaml<7,>=6
Requires-Dist: rich<14,>=13
Requires-Dist: rich-argparse<2,>=1
Requires-Dist: types-colorama<1,>=0.4
Requires-Dist: typing-extensions<5,>=4
Provides-Extra: prod
Requires-Dist: colorama==0.4.6; extra == "prod"
Requires-Dist: markdown-it-py==3.0.0; extra == "prod"
Requires-Dist: mdurl==0.1.2; extra == "prod"
Requires-Dist: mistletoe==1.3.0; extra == "prod"
Requires-Dist: pygments==2.17.2; extra == "prod"
Requires-Dist: rich==13.7.1; extra == "prod"
Requires-Dist: rich-argparse==1.4.0; extra == "prod"
Requires-Dist: types-colorama==0.4.15.20240311; extra == "prod"
Requires-Dist: typing-extensions==4.11.0; extra == "prod"
Requires-Dist: pyyaml==6.0.1; extra == "prod"
Provides-Extra: dev
Requires-Dist: argcomplete==3.3.0; extra == "dev"
Requires-Dist: autoflake==2.3.1; extra == "dev"
Requires-Dist: backports-tarfile==1.1.1; extra == "dev"
Requires-Dist: beautifulsoup4==4.12.3; extra == "dev"
Requires-Dist: bs4==0.0.2; extra == "dev"
Requires-Dist: certifi==2024.2.2; extra == "dev"
Requires-Dist: cffi==1.16.0; extra == "dev"
Requires-Dist: cfgv==3.4.0; extra == "dev"
Requires-Dist: changeguard==0.3.1; extra == "dev"
Requires-Dist: charset-normalizer==3.3.2; extra == "dev"
Requires-Dist: colorama==0.4.6; extra == "dev"
Requires-Dist: cryptography==42.0.5; extra == "dev"
Requires-Dist: defusedxml==0.7.1; extra == "dev"
Requires-Dist: distlib==0.3.8; extra == "dev"
Requires-Dist: docutils==0.20.1; extra == "dev"
Requires-Dist: filelock==3.14.0; extra == "dev"
Requires-Dist: identify==2.5.36; extra == "dev"
Requires-Dist: idna==3.7; extra == "dev"
Requires-Dist: importlib-metadata==7.1.0; extra == "dev"
Requires-Dist: importlib-resources==6.4.0; extra == "dev"
Requires-Dist: isort==5.13.2; extra == "dev"
Requires-Dist: jaraco-classes==3.4.0; extra == "dev"
Requires-Dist: jaraco-context==5.3.0; extra == "dev"
Requires-Dist: jaraco-functools==4.0.1; extra == "dev"
Requires-Dist: jeepney==0.8.0; extra == "dev"
Requires-Dist: jinja2==3.1.3; extra == "dev"
Requires-Dist: keyring==25.2.0; extra == "dev"
Requires-Dist: markdown-it-py==3.0.0; extra == "dev"
Requires-Dist: markupsafe==2.1.5; extra == "dev"
Requires-Dist: mdremotifier==0.3.1; extra == "dev"
Requires-Dist: mdurl==0.1.2; extra == "dev"
Requires-Dist: mistletoe==1.3.0; extra == "dev"
Requires-Dist: more-itertools==10.2.0; extra == "dev"
Requires-Dist: mypy==1.8.0; extra == "dev"
Requires-Dist: mypy-extensions==1.0.0; extra == "dev"
Requires-Dist: nh3==0.2.17; extra == "dev"
Requires-Dist: nodeenv==1.8.0; extra == "dev"
Requires-Dist: pathspec==0.12.1; extra == "dev"
Requires-Dist: pexpect==4.9.0; extra == "dev"
Requires-Dist: pkginfo==1.10.0; extra == "dev"
Requires-Dist: platformdirs==4.2.1; extra == "dev"
Requires-Dist: pre-commit==3.5.0; extra == "dev"
Requires-Dist: ptyprocess==0.7.0; extra == "dev"
Requires-Dist: pycparser==2.22; extra == "dev"
Requires-Dist: pyflakes==3.2.0; extra == "dev"
Requires-Dist: pygments==2.17.2; extra == "dev"
Requires-Dist: pyright==1.1.352; extra == "dev"
Requires-Dist: pyyaml==6.0.1; extra == "dev"
Requires-Dist: readme-renderer==43.0; extra == "dev"
Requires-Dist: requests==2.31.0; extra == "dev"
Requires-Dist: requests-toolbelt==1.0.0; extra == "dev"
Requires-Dist: rfc3986==2.0.0; extra == "dev"
Requires-Dist: rich==13.7.1; extra == "dev"
Requires-Dist: rich-argparse==1.4.0; extra == "dev"
Requires-Dist: secretstorage==3.3.3; extra == "dev"
Requires-Dist: snipinator==1.4.0; extra == "dev"
Requires-Dist: soupsieve==2.5; extra == "dev"
Requires-Dist: toml-sort==0.23.1; extra == "dev"
Requires-Dist: tomli==2.0.1; extra == "dev"
Requires-Dist: tomlkit==0.12.4; extra == "dev"
Requires-Dist: twine==5.0.0; extra == "dev"
Requires-Dist: types-beautifulsoup4==4.12.0.20240504; extra == "dev"
Requires-Dist: types-colorama==0.4.15.20240311; extra == "dev"
Requires-Dist: types-html5lib==1.1.11.20240228; extra == "dev"
Requires-Dist: types-pyyaml==6.0.12.20240311; extra == "dev"
Requires-Dist: typing-extensions==4.10.0; extra == "dev"
Requires-Dist: urllib3==2.2.1; extra == "dev"
Requires-Dist: virtualenv==20.26.0; extra == "dev"
Requires-Dist: xmltodict==0.13.0; extra == "dev"
Requires-Dist: yapf==0.40.2; extra == "dev"
Requires-Dist: yq==3.2.3; extra == "dev"
Requires-Dist: zipp==3.18.1; extra == "dev"

<!--

WARNING: This file is auto-generated by snipinator. Do not edit directly.
SOURCE: `README.md.jinja2`.

-->
<!--







-->

# <div align="center">![mdreftidy][1]</div>

<div align="center">

</div>

<div align="center">

<!-- Icons from https://lucide.dev/icons/users -->
<!-- Icons from https://lucide.dev/icons/laptop-minimal -->

![**Audience:** Developers][2] ![**Platform:** Linux][3]

</div>

<p align="center">
  <strong>
    <a href="#-features">🎇Features</a>
    &nbsp;&bull;&nbsp;
    <a href="#-installation">🏠Installation</a>
    &nbsp;&bull;&nbsp;
    <a href="#-usage">🚜Usage</a>
    &nbsp;&bull;&nbsp;
    <a href="#-command-line-options">💻CLI</a>
    &nbsp;&bull;&nbsp;
    <a href="#-examples">💡Examples</a>
    &nbsp;&bull;&nbsp;
    <a href="#-requirements">✅Requirements</a>
  </strong>
</p>

<div align="center">

![Top language][4] [![GitHub License][5]][6] [![PyPI - Version][7]][8]
[![Python Version][9]][8]

**CLI to tidy ({renumber,move-to-bottom,sort,clean}) up {image,link} references
for markdown**

</div>

---

<div align="center">

|                   | Status                      | Stable                    | Unstable                  |                    |
| ----------------- | --------------------------- | ------------------------- | ------------------------- | ------------------ |
| **[Master][10]**  | [![Build and Test][11]][12] | [![since tagged][13]][14] |                           | ![last commit][15] |
| **[Develop][16]** | [![Build and Test][17]][12] | [![since tagged][18]][19] | [![since tagged][20]][21] | ![last commit][22] |

</div>

<img alt="Demo" src="https://raw.githubusercontent.com/realazthat/mdreftidy/v0.3.1/.github/demo.gif" width="100%"/>

## ❔ What

What mdreftidy does:

Turn this ([./mdreftidy/examples/EXAMPLE.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/EXAMPLE.md)):

<!---->
```md
# Example markdown file

## Reference link: Out of order

[Reference link: Out of order 1][3], [Reference link: Out of order 2][2].

[2]: ./reference-link-out-of-order-2

## Footnotes

[6]: ./unused-reference-link-6
[3]: ./reference-link-out-of-order-3
[1]: ./unused-reference-link-1

```
<!---->

Into this
([./mdreftidy/examples/EXAMPLE.all-opts.tidied.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/EXAMPLE.all-opts.tidied.md)):

<!---->
```md
# Example markdown file

## Reference link: Out of order

[Reference link: Out of order 1][1], [Reference link: Out of order 2][2].


## Footnotes

[1]: ./reference-link-out-of-order-3
[2]: ./reference-link-out-of-order-2

```
<!---->

This is useful for uploading `README.md` files to third-party sites, like the
npmjs.com registry, or pypi.org registry, because these registries will break
the local images in your README when displayed on their sites.

## 🎇 Features

- Renumbers references by order used.
- Optionally removes unused references.
- Optionally moves references to the bottom.
- Optionally sorts reference blocks.

## 🏠 Installation

```bash
# Install from pypi (https://pypi.org/project/mdreftidy/)
pip install mdreftidy

# Install from git (https://github.com/realazthat/mdreftidy)
pip install git+https://github.com/realazthat/mdreftidy.git@v0.3.1
```

## 🚜 Usage

Example README: ([./mdreftidy/examples/EXAMPLE.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/EXAMPLE.md)):

<!---->
```md
# Example markdown file

## Reference link: Out of order

[Reference link: Out of order 1][3], [Reference link: Out of order 2][2].

[2]: ./reference-link-out-of-order-2

## Footnotes

[6]: ./unused-reference-link-6
[3]: ./reference-link-out-of-order-3
[1]: ./unused-reference-link-1

```
<!---->

Generating the README:

<!---->
```bash
$ python -m mdreftidy.cli ./mdreftidy/examples/EXAMPLE.md --move-to-bottom --remove-unused --sort-ref-blocks --renumber -o - 2>/dev/null
# Example markdown file

## Reference link: Out of order

[Reference link: Out of order 1][1], [Reference link: Out of order 2][2].


## Footnotes

[1]: ./reference-link-out-of-order-3
[2]: ./reference-link-out-of-order-2

```
<!---->

## 💻 Command Line Options

<!---->
<img alt="Output of `python -m mdreftidy.cli --help`" src="https://raw.githubusercontent.com/realazthat/mdreftidy/v0.3.1/README.help.generated.svg"/>
<!-- -->

## 💡 Examples

- Example:
  - Original: [./mdreftidy/examples/EXAMPLE.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/EXAMPLE.md).
  - Tidied:
    [./mdreftidy/examples/EXAMPLE.all-opts.tidied.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/EXAMPLE.all-opts.tidied.md).
  - Generation script: [./mdreftidy/examples/example.sh](https://github.com/realazthat/mdreftidy/blob/v0.3.1/mdreftidy/examples/example.sh).

<!-- TODO: Rebuild this for mdreftidy
- Projects using mdreftidy:
  - [realazthat/snipinator](https://github.com/realazthat/snipinator), See
    [snipinator/README.md.jinja2](https://github.com/realazthat/snipinator/blob/61cb88593baa099dc375cf5fd40679e4be673fc5/README.md.jinja2).
  - [github.com/realazthat/changeguard](https://github.com/realazthat/changeguard),
    See
    [changeguard/README.md.jinja2](https://github.com/realazthat/changeguard/blob/87d5104b52e651bb9195a3d46dd7f050acbcb534/README.md.jinja2).
  - [github.com/realazthat/comfy-catapult](https://github.com/realazthat/comfy-catapult),
    See
    [comfy-catapult/README.md.jinja2](https://github.com/realazthat/comfy-catapult/blob/ff353d48b25fa7b9c35fa11b31d5f2b3039c41c8/README.md.jinja2).
  - [github.com/realazthat/comfylowda](https://github.com/realazthat/comfylowda),
    See
    [comfylowda/README.md.jinja2](https://github.com/realazthat/comfylowda/blob/e01a32c38107aa0b89ccea21c4678d193a186a78/README.md.jinja2).
  - [github.com/realazthat/excalidraw-brute-export-cli](https://github.com/realazthat/excalidraw-brute-export-cli),
    See
    [excalidraw-brute-export-cli/README.md.jinja2](https://github.com/realazthat/excalidraw-brute-export-cli/blob/54a3b5b08b644e61c721ab565c576094234c5cc7/README.md.jinja2).
-->

## ✅ Requirements

- Linux-like environment
  - Why: Uses pexpect.spawn().
- Python 3.8+
  - Why: Some dev dependencies require Python 3.8+.

### Tested Platforms

- WSL2 Ubuntu 20.04, Python `3.8.0`.
- Ubuntu 20.04, Python `3.8.0, 3.9.0, 3.10.0, 3.11.0, 3.12.0`, tested in GitHub Actions
  workflow ([build-and-test.yml](https://github.com/realazthat/mdreftidy/blob/v0.3.1/.github/workflows/build-and-test.yml)).

## 🤏 Versioning

We use SemVer for versioning. For the versions available, see the tags on this
repository.

## 🔑 License

This project is licensed under the MIT License - see the
[./LICENSE.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/LICENSE.md) file for details.

## 🙏 Thanks

Main libraries used in mdreftidy are:

- Markdown AST: [mistletoe](https://github.com/miyuchina/mistletoe).
- Colorful CLI help: [rich-argparse](https://github.com/hamdanal/rich-argparse).

## 🤝 Related Projects

Not complete, and not necessarily up to date. Make a PR
([contributions](#-contributions)) to insert/modify.

| Project           | Stars | Last Update  | Language | Platform | Similarity X Obviousness |
| ----------------- | ----- | ------------ | -------- | -------- | ------------------------ |
| [dce/mdrenum][60] | 2     | `2023/11/16` | JS       | CLI      | ⭐⭐⭐⭐⭐                    |

## 🫡 Contributions

### Development environment: Linux-like

- For running `pre.sh` (Linux-like environment).

  - From [./.github/dependencies.yml](https://github.com/realazthat/mdreftidy/blob/v0.3.1/.github/dependencies.yml), which is used for
    the GH Action to do a fresh install of everything:

    ```yaml
    bash: scripts.
    findutils: scripts.
    grep: tests.
    xxd: tests.
    git: scripts, tests.
    xxhash: scripts (changeguard).
    rsync: out-of-directory test.
    expect: for `unbuffer`, useful to grab and compare ansi color symbols.
    jq: dependency for [yq](https://github.com/kislyuk/yq), which is used to generate
      the README; the README generator needs to use `tomlq` (which is a part of `yq`)
      to query `pyproject.toml`.

    ```

  - Requires `pyenv`, or an exact matching version of python as in
    [.python-version](https://github.com/realazthat/mdreftidy/blob/v0.3.1/.python-version) (which is currently
    `3.8.0 `).
  - `jq`, ([installation](https://jqlang.github.io/jq/)) required for
    [yq](https://github.com/kislyuk/yq), which is itself required for our
    [./README.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/README.md) generation, which uses `tomlq` (from the
    [yq](https://github.com/kislyuk/yq) package) to include version strings from
    [./pyproject.toml](https://github.com/realazthat/mdreftidy/blob/v0.3.1/pyproject.toml).
  - act (to run the GH Action locally):
    - Requires nodejs.
    - Requires Go.
    - docker.
  - Generate animation:
    - docker

### Commit Process

1. (Optionally) Fork the `develop` branch.
2. Stage your files: `git add path/to/file.py`.
3. `bash ./scripts/pre.sh`, this will format, lint, and test the code.
4. `git status` check if anything changed (generated
   [./README.md](https://github.com/realazthat/mdreftidy/blob/v0.3.1/README.md) for example), if so, `git add` the
   changes, and go back to the previous step.
5. `git commit -m "..."`.
6. Make a PR to `develop` (or push to develop if you have the rights).

## 🔄🚀 Release Process

These instructions are for maintainers of the project.

1. In the `develop` branch, run `bash ./scripts/pre.sh` to ensure
   everything is in order.
2. In the `develop` branch, bump the version in
   [./pyproject.toml](https://github.com/realazthat/mdreftidy/blob/v0.3.1/pyproject.toml), following semantic versioning
   principles. Also modify the `last_unstable_release` and `last_stable_release`
   in the `[tool.mdreftidy-project-metadata]` table as appropriate. Run
   `bash ./scripts/pre.sh` to ensure everything is in order.
3. In the `develop` branch, commit these changes with a message like
   `"Prepare release X.Y.Z"`. (See the contributions section
   [above](#commit-process)).
4. Merge the `develop` branch into the `master` branch:
   `git checkout master && git merge develop --no-ff`.
5. `master` branch: Tag the release: Create a git tag for the release with
   `git tag -a vX.Y.Z -m "Version X.Y.Z"`.
6. Publish to PyPI: Publish the release to PyPI with
   `bash ./scripts/deploy-to-pypi.sh`.
7. Push to GitHub: Push the commit and tags to GitHub with
   `git push && git push --tags`.
8. The `--no-ff` option adds a commit to the master branch for the merge, so
   refork the develop branch from the master branch:
   `git checkout develop && git merge master`.
9. Push the develop branch to GitHub: `git push origin develop`.

<!-- Logo from https://lucide.dev/icons/users -->

<!-- Logo from https://lucide.dev/icons/laptop-minimal -->

[1]: https://raw.githubusercontent.com/realazthat/mdreftidy/v0.3.1/.github/logo-exported.svg
[2]: https://img.shields.io/badge/Audience-Developers-0A1E1E?style=plastic&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLXVzZXJzIj48cGF0aCBkPSJNMTYgMjF2LTJhNCA0IDAgMCAwLTQtNEg2YTQgNCAwIDAgMC00IDR2MiIvPjxjaXJjbGUgY3g9IjkiIGN5PSI3IiByPSI0Ii8+PHBhdGggZD0iTTIyIDIxdi0yYTQgNCAwIDAgMC0zLTMuODciLz48cGF0aCBkPSJNMTYgMy4xM2E0IDQgMCAwIDEgMCA3Ljc1Ii8+PC9zdmc+
[3]: https://img.shields.io/badge/Platform-Linux-0A1E1E?style=plastic&logo=data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJsdWNpZGUgbHVjaWRlLWxhcHRvcC1taW5pbWFsIj48cmVjdCB3aWR0aD0iMTgiIGhlaWdodD0iMTIiIHg9IjMiIHk9IjQiIHJ4PSIyIiByeT0iMiIvPjxsaW5lIHgxPSIyIiB4Mj0iMjIiIHkxPSIyMCIgeTI9IjIwIi8+PC9zdmc+
[4]: https://img.shields.io/github/languages/top/realazthat/mdreftidy.svg?&cacheSeconds=28800&style=plastic&color=0A1E1E
[5]: https://img.shields.io/github/license/realazthat/mdreftidy?style=plastic&color=0A1E1E
[6]: https://github.com/realazthat/mdreftidy/blob/v0.3.1/LICENSE.md
[7]: https://img.shields.io/pypi/v/mdreftidy?style=plastic&color=0A1E1E
[8]: https://pypi.org/project/mdreftidy/
[9]: https://img.shields.io/pypi/pyversions/mdreftidy?style=plastic&color=0A1E1E
[10]: https://github.com/realazthat/mdreftidy/tree/master
[11]: https://img.shields.io/github/actions/workflow/status/realazthat/mdreftidy/build-and-test.yml?branch=master&style=plastic
[12]: https://github.com/realazthat/mdreftidy/actions/workflows/build-and-test.yml
[13]: https://img.shields.io/github/commits-since/realazthat/mdreftidy/v0.3.1/master?style=plastic
[14]: https://github.com/realazthat/mdreftidy/compare/v0.3.1...master
[15]: https://img.shields.io/github/last-commit/realazthat/mdreftidy/master?style=plastic
[16]: https://github.com/realazthat/mdreftidy/tree/develop
[17]: https://img.shields.io/github/actions/workflow/status/realazthat/mdreftidy/build-and-test.yml?branch=develop&style=plastic
[18]: https://img.shields.io/github/commits-since/realazthat/mdreftidy/v0.3.1/develop?style=plastic
[19]: https://github.com/realazthat/mdreftidy/compare/v0.3.1...develop
[20]: https://img.shields.io/github/commits-since/realazthat/mdreftidy/v0.3.1/develop?style=plastic
[21]: https://github.com/realazthat/mdreftidy/compare/v0.3.1...develop
[22]: https://img.shields.io/github/last-commit/realazthat/mdreftidy/develop?style=plastic
