Tool for markdown blog migrate
This tool do the things below:
- Input a markdown file, download all pictures from "![](https://xxx.xxx\)", saved as {%d}.xxx
- Modify the "![](https://xxx.xxx\)" to the request form(for example, {{<figure src = "{0}" title = "" lightbox = "true">}} which is required by Hugo)
For example:
Input markdown:
Output markdown:
In the same time, 0.png is downloaded into the path where Input markdown file exist.
git clone this repo, add envionment variables(optional)
python3 blog_transformer.py -f YorMarkdown.md
if envionment variables is set, the script can be run anywhere:
blog_transformer.py -f YorMarkdown.md
Or use it by import to python
from blog_transformer import BlogTransformer
bt = BlogTransformer()
md = bt.run(YOUR_FILE_NAME, save_path=YOUR_DIR, save=True)
Pipeline tool based on blog_transformer, it is a tool for blog building with specified header templete (here "templete.md" is used), the header help blog generator like hugo to generate html correctly.
just run
python3 pipeline.py -f YorMarkdown.md -t YourTime
Then, a new floder which use the same name as "YorMarkdown.md" will be created and pics in "YorMarkdown.md" will be downloaded into it. "YorMarkdown.md" will be modified using the templete and finally saved as index.md. "YourTime" is the time when "YorMarkdown.md" is writed, YourTime should use YYYY-MM-DD format.