自动删除markdown中未引用的图片

fengbohan 59482c359e add readme 9 tháng trước cách đây
.vscode 0407d02129 init 9 tháng trước cách đây
test.assets 0407d02129 init 9 tháng trước cách đây
ReadMe.md 59482c359e add readme 9 tháng trước cách đây
remove.py 0407d02129 init 9 tháng trước cách đây
requirements.txt 59482c359e add readme 9 tháng trước cách đây
test.md 0407d02129 init 9 tháng trước cách đây

ReadMe.md

功能列表

  • 删除当前Markdown文件中未引用的图片
  • 发现未引用图片后,会打印出来,询问是否需要删除

原理:获取指定目录下所有的图片名字,然后在文件中检索是否存在。若不存在则认为是未引用图片。

==注意==只要文章中存在图片的命令(带后缀),即使没有正确按照Markdown语法引用,也认为是引用的。使用的时候注意一下

快速开始

  1. 安装依赖

    pip install -r requirements.txt
    
  2. 运行程序

    python remove.py test.md
    
  3. 运行结果

    .\test.md encoding is utf-8, confidence: 0.99
    img:img.png
    find 1 unuse img files:
    test.assets\img.png
    would you want to delete them?(y or n):y
    delete test.assets\img.png
    

用法说明

usage: remove.py [-h] [-a ASSETS] file

positional arguments:
  file                  specifi the markdown file

options:
  -h, --help            show this help message and exit
  -a ASSETS, --assets ASSETS
                        specifi the img dir