Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aharoj/markdownimagelinker
A universal markdown linker for note-taking apps, management tools, and markdown editors. Simplify image path management for local and GitHub workflows with ease!
https://github.com/aharoj/markdownimagelinker
cli file-cleanup image-linker markdown obsidian-md
Last synced: 18 days ago
JSON representation
A universal markdown linker for note-taking apps, management tools, and markdown editors. Simplify image path management for local and GitHub workflows with ease!
- Host: GitHub
- URL: https://github.com/aharoj/markdownimagelinker
- Owner: aharoJ
- License: mit
- Created: 2023-01-21T05:37:28.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-11-26T06:55:30.000Z (29 days ago)
- Last Synced: 2024-11-26T07:30:03.381Z (29 days ago)
- Topics: cli, file-cleanup, image-linker, markdown, obsidian-md
- Homepage: https://aharoj.io
- Size: 7.6 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Universal Markdown Linker for GITHUB**
**MarkdownImageLinker** is a Python tool designed to simplify and manage image links in markdown files. It automatically fixes relative paths, handles file movements or renaming, and ensures your markdown images remain viewable, regardless of how your directories or files are structured. Perfect for GitHub documentation, note-taking apps like Obsidian, or any markdown-based workflows.
## π Features
- **Dynamic Path Adjustment**: Automatically updates image paths when markdown files or attachments are moved, renamed, or nested in subdirectories.
- **Dual Operations**:
- **Clean**: Simplifies image paths into viewable URLs, handling URL encoding for filenames with spaces or special characters.
- **Link**: Reattaches valid paths for images located in a designated attachment directory, ensuring seamless previews.
- **Alt Text Support**: Handles image links with or without alt text, preserving metadata and annotations.
- **Recursive Directory Traversal**: Processes all markdown files in the workspace, including deeply nested subdirectories.
- **Cross-App Compatibility**: Tested and compatible with markdown-based apps like Obsidian, Typora, and GitHub.## π How It Works
MarkdownImageLinker scans your workspace, identifies image links, and ensures all paths are valid and consistent. It uses Python's `os` and `re` modules for file handling and regex-based pattern matching.
### Workflow:
1. **Clean**: Simplifies complex relative links (e.g., `../../attachments/image.png`) into clean, encoded paths.
2. **Link**: Updates paths to point to a centralized attachment directory, ensuring accurate references even after file reorganizations.---
## π Installation
> Youβll need to clone the repository and execute the prebuilt binary file.
Hereβs how:
1. Clone the repository:
```bash
git clone https://github.com/aharoJ/MarkdownImageLinker.git
cd MarkdownImageLinker
```2. Grant execute permissions to the binary:
```bash
chmod +x link
```3. Run the tool:
```bash
./link
```---
## π Usage
Run the script and choose an option:
```plaintext
Select an option:
[1] Clean
[2] Link
[q] Quit
```- **[1] Clean**: Simplifies and sanitizes image paths for readability and compatibility.
- **[2] Link**: Adjusts image paths to reference a centralized `attachments` directory.
- **[q] Quit**: Exits the tool.---
## π Examples
### Before:
```markdown
![Diagram](../../../../attachments/diagram.png)
![Alt Text](../z/image with spaces.png)
```### After (Clean Operation):
```markdown
![Diagram](diagram.png)
![Alt Text](image%20with%20spaces.png)
```### After (Link Operation):
```markdown
![Diagram](../z/diagram.png)
![Alt Text](../z/image%20with%20spaces.png)
```---
## π€ Contributing
Contributions are welcome! If you have ideas for new features or improvements, feel free to open an issue or submit a pull request.
---
## π¨βπ» Author
- [Angel J. Haro](https://aharoj.io)
## Images
> options
![alt text]()
> un-link
![alt text](z/unlink.png)
> link
![alt text](z/link.png)