念两句诗

亿图脑图导出

2023-06-01 浏览 小技巧 197字 1 min read

思路——>先导出文本(免费的,文本可能出现排版错误,需要微调)——> python处理文本,转换为md格式——>使用markmap ——>可导出为svg或者html格式

样例网站

https://mm.edrawsoft.cn/template/156937 超巨大的思维导图

处理脚本

with open('xx.txt', 'r', encoding='utf-8') as f:
    lines = f.readlines()

import re
f = open('xx.mm.md', 'w', encoding='utf-8')
for line in lines:
    # 匹配中文字符
    pattern = re.compile(r'[^\s*]')
    match = pattern.search(line)
    # print(match)
    if match:
        spaces_before = len(re.findall(r'^\s*', line[:match.start()])[0])
        # line = line.replace('\t', '')
        if spaces_before<=5:
            line = line[:match.start()] + '#' + '#' * spaces_before + ' ' + line[match.start():]
        else:
            line = line[:match.start()] + '  ' * (spaces_before-6) + '- ' + line[match.start():]
        line = line.replace('\t', '')
    print(line, end='')
    f.write(line)
f.close()

使用markmap

可以使用在线网址,也可以安装vscode插件——markmap

Download可以下载Html或者Svg格式

EOF