Remotify local links in README.md; Make markdown READMEs self contained for publication to sites other than GH, such as npm, pypi.
Project description
🎇Features • 🏠Installation • 🚜Usage • 💻CLI • 💡Examples
❔ What
What mdremotifier does:
Turn this (./examples/SIMPLE.md):
# Example markdown file
## Local link
[LICENSE.md](./LICENSE.md).
## Local image
![local image](./img.png).
Into this (./examples/SIMPLE.remotified.md):
# Example markdown file
## Local link
[LICENSE.md](https://github.com/realazthat/mdremotifier/blob/master/LICENSE.md).
## Local image
![local image](https://raw.githubusercontent.com/realazthat/mdremotifier/master/img.png).
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.
See https://pypi.org/project/mdremotifier/, notice how all of the images are not broken.
🎇 Features
- 📷🔗📡🌐🖼️ Replace local URLs with raw.githubusercontent.com URLs.
🏠 Installation
# Install from pypi (https://pypi.org/project/mdremotifier/)
pip install mdremotifier
# Install from git (https://github.com/realazthat/mdremotifier)
pip install git+https://github.com/realazthat/mdremotifier.git@v0.5.0
🚜 Usage
Example README: (./examples/SIMPLE.md):
# Example markdown file
## Local link
[LICENSE.md](./LICENSE.md).
## Local image
![local image](./img.png).
Generating the README:
# Using this command:
# View the template file.
cat "examples/SIMPLE.md"
python -m mdremotifier.cli \
-i "examples/SIMPLE.md" \
--url-prefix https://github.com/realazthat/mdremotifier/blob/master/ \
--img-url-prefix https://raw.githubusercontent.com/realazthat/mdremotifier/master/ \
-o "examples/SIMPLE.remotified.md"
# View the remotified file.
cat "examples/SIMPLE.remotified.md"
Result:
# Example markdown file
## Local link
[LICENSE.md](https://github.com/realazthat/mdremotifier/blob/master/LICENSE.md).
## Local image
![local image](https://raw.githubusercontent.com/realazthat/mdremotifier/master/img.png).
Full example:
💻 Command Line Options
💡 Examples
- mdremotifier's own
README
:- Original: ./README.md.
- Remotified: ./.github/README.remotified.md.
- Generation script: ./scripts/generate-readme.sh.
- Example:
- Original: ./examples/SIMPLE.md.
- Remotified: ./examples/SIMPLE.remotified.md.
- Generation script: ./examples/simple_example.sh.
- Projects using mdremotifier:
- realazthat/snipinator.
- README: snipinator/README.md.
- Generation script: snipinator/scripts/generate-readme.sh#L29.
- Remotified: snipinator/README.md.
- github.com/realazthat/excalidraw-brute-export-cli.
- README: excalidraw-brute-export-cli/README.md.
- Generation script: excalidraw-brute-export-cli/scripts/generate-readme.sh#L65.
- Remotified: excalidraw-brute-export-cli/README.md.
- realazthat/snipinator.
✅ 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).
🐳 Docker Image
Docker images are published to ghcr.io/realazthat/mdremotifier at each tag.
# View the template file.
cat "examples/SIMPLE.md"
# Use the published images at ghcr.io/realazthat/mdremotifier.
# /data in the docker image is the working directory, so paths are simpler.
docker run --rm --tty \
-v "${PWD}:/data" \
ghcr.io/realazthat/mdremotifier:v0.5.0 \
-i "examples/SIMPLE.md" \
--url-prefix https://github.com/realazthat/mdremotifier/blob/master/ \
--img-url-prefix https://raw.githubusercontent.com/realazthat/mdremotifier/master/ \
-o "examples/SIMPLE.remotified.md"
# View the remotified file.
cat "examples/SIMPLE.remotified.md"
If you want to build the image yourself, you can use the Dockerfile in the repository.
docker build -t my-mdremotifier-image .
# View the template file.
cat "examples/SIMPLE.md"
# /data in the docker image is the working directory, so paths are simpler.
docker run --rm --tty \
-v "${PWD}:/data" \
my-mdremotifier-image \
-i "examples/SIMPLE.md" \
--url-prefix https://github.com/realazthat/mdremotifier/blob/master/ \
--img-url-prefix https://raw.githubusercontent.com/realazthat/mdremotifier/master/ \
-o "examples/SIMPLE.remotified.md"
# View the remotified file.
cat "examples/SIMPLE.remotified.md"
🤏 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 file for details.
🙏 Thanks
Main libraries used in mdremotifier are:
- Markdown AST: mistletoe.
- Colorful CLI help: rich-argparse.
🤝 Related Projects
Not complete, and not necessarily up to date. Make a PR (contributions) to insert/modify.
Project | Stars | Last Update | Language | Platform | Similarity X Obviousness |
---|---|---|---|---|---|
bdashore3/remark-github-images | 0 | 2022/12/29 |
JS | CLI | ⭐⭐⭐⭐⭐ |
laobie/WriteMarkdownLazily | 36 | 2024/01/06 |
Python | CLI | ⭐⭐⭐⭐ |
crh19970307/mdul | 1 | 2020/02/01 |
Python | CLI | ⭐⭐⭐⭐ |
SkyLee424/Go-MarkDown-Image-Transfer-Helper | 0 | 2024/03/25 |
Go | CLI | ⭐⭐⭐⭐ |
jen6/imgo | 0 | 2020/03/18 |
Pyhon | CLI | ⭐⭐⭐⭐ |
chocoluffy/lazy-markdown | 0 | 2016/11/20 |
Python | CLI | ⭐⭐⭐⭐ |
loheagn/gopic | 0 | 2021/11/24 |
Go | CLI | ⭐⭐⭐⭐ |
Undertone0809/imarkdown | 57 | 2024/01/06 |
Python | Python | ⭐⭐⭐ |
ravgeetdhillon/markdown-imgur-upload | 1 | 2022/03/26 |
Python | CLI | ⭐⭐⭐ |
🫡 Contributions
Development environment: Linux-like
-
For running
pre.sh
(Linux-like environment).-
From ./.github/dependencies.yml, which is used for the GH Action to do a fresh install of everything:
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 (which is currently3.8.0
). -
jq
, (installation) required for yq, which is itself required for our ./README.md generation, which usestomlq
(from the yq package) to include version strings from ./pyproject.toml. -
act (to run the GH Action locally):
- Requires nodejs.
- Requires Go.
- docker.
-
Generate animation:
- docker
-
docker (for building the docker image).
-
Commit Process
- (Optionally) Fork the
develop
branch. - Stage your files:
git add path/to/file.py
. bash ./scripts/pre.sh
, this will format, lint, and test the code.git status
check if anything changed (generated ./README.md for example), if so,git add
the changes, and go back to the previous step.git commit -m "..."
.- Make a PR to
develop
(or push to develop if you have the rights).
🔄🚀 Release Process
These instructions are for maintainers of the project.
- In the
develop
branch, runbash ./scripts/pre.sh
to ensure everything is in order. - In the
develop
branch, bump the version in ./pyproject.toml, following semantic versioning principles. Also modify thelast_release
andlast_stable_release
in the[tool.mdremotifier-project-metadata]
table as appropriate. Runbash ./scripts/pre.sh
to ensure everything is in order. - In the
develop
branch, commit these changes with a message like"Prepare release X.Y.Z"
. (See the contributions section above). - Merge the
develop
branch into themaster
branch:git checkout master && git merge develop --no-ff
. master
branch: Tag the release: Create a git tag for the release withgit tag -a vX.Y.Z -m "Version X.Y.Z"
.- Publish to PyPI: Publish the release to PyPI with
bash ./scripts/deploy-to-pypi.sh
. - Push to GitHub: Push the commit and tags to GitHub with
git push && git push --tags
. - 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
. - Push the develop branch to GitHub:
git push origin develop
.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mdremotifier-0.5.0.tar.gz
.
File metadata
- Download URL: mdremotifier-0.5.0.tar.gz
- Upload date:
- Size: 20.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c63ac1b6f151b5b9e16c19a8a96298779365ff719bf7225cbcc78526aa7ecc78 |
|
MD5 | 03c9a109160e0712f71d6c91c552a565 |
|
BLAKE2b-256 | 070f16abd495232908ac24515c708cfe8485032774e2a75611662441dcf21209 |
File details
Details for the file mdremotifier-0.5.0-py3-none-any.whl
.
File metadata
- Download URL: mdremotifier-0.5.0-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a8afe6c71169c786aad74295c190a855734815a6d5778d5143de43e99e8f387 |
|
MD5 | 14fa6834fe362c3f11fd98dadcbd2f06 |
|
BLAKE2b-256 | e9f54f1e2152d1b97a82292a9624bc5a9e1c32262288bb9abc69779eeab852e1 |