Yuque converts and publishes CSDN and Yuque exported pictures and pictures cannot be recognized (for typora)

Yuque to CSDN, quick solution

  1. First enter the web page note, then add /markdown after the web page address
    insert image description here

  2. Copy the markdown to the release page of CSDN.

  3. If the picture cannot be displayed:
    a. On the edit page, replace [object Object] with %5Bobject%20Object%5D, and then the picture can be seen normally on the preview page.
    insert image description here

    b. ctrl+G is a shortcut replacement (on CSDN)

  • For the normal CSDN image format, just copy and paste, and there is nothing special about it.
    insert image description here

Yuque export and modify picture link

  • If you use Yuque to export markdown, there is another way to deal with it. In the local markdown, Yuque can display this format. This is after correction.
    insert image description here
    In other words, Yuque exported too many pictures # clientId=xxxx, so the pictures could not be displayed.
    insert image description here
  • Here I attach my own converted python script, find a folder, put in the markdown to be converted, and then run it, and the converted markdown will be output in a local folder output.
import re
import os
# 处理文件中的语雀图片链接
def processMarkdownImage(file, filename):
    # 判断输出目录是否存在
    output_dir = os.path.join("./output")
    if not os.path.exists(output_dir):
        os.mkdir(output_dir)
    # 设置输出文件名为 xxx (修).md
    output_file = os.path.join(output_dir , str(filename.split(".")[0]) + "(修).md")
    fw = open(output_file, "w", encoding="utf-8") # 打开文件
    # 读取文件
    with open(file,encoding='utf-8') as f:
        lines = f.readlines()
        for line in lines:
            if r'#clientId=' in line:
                # 都在同一行,所以直接就处理图片链接了
                line = line.split('#clientId=')[0] + ")"
                # 找到这个以后,接下来找到匹配的 )
            fw.write(line)

    fw.close()

# 读取档期那目录下面所有的.md文件
now_dir = os.path.join(".")
for filename in os.listdir(now_dir):
    # 只获取*.md文件
    if filename.endswith(".md"):
        processMarkdownImage(os.path.join(now_dir, filename), filename)

Guess you like

Origin blog.csdn.net/Fly_the_start/article/details/127603280