脚本内容
#!/usr/bin/env ruby
File.open("../这里放你的MarkDown文本名.md", 'r') do |f|
f.each_line do |line|
forbidden_words = [
'Table of contents',
'define',
'pragma',
'Zen and the Art of the Objective-C Craftsmanship']
next if !line.start_with?("#") || forbidden_words.any? { |w| line =~ /#{w}/ }
title = line.gsub("#", "").strip
href = title.gsub(" ", "-").downcase
puts " " * (line.count("#")-1) + "* [#{title}](\##{href})"
end
end
操作步骤
- 1.新建一个文本,把上面的脚本内容粘贴进入,注意文件之间的目录层次.把文件后缀名改为rb如下图:

- 2.打开终端.前提需要安装ruby环境
执行ruby脚本 - 3.终端打印出目录,之后把打印出来的目录粘贴到文本中即可

图片居中
<div align="center">
<img src="../Pic/**.jpg" alt="..." width="300">
</div>