import os import sys import json import re directory_file = sys.argv[1] docs_path = sys.argv[2] success = True def check_md_content(md_file): global success if not os.path.exists(md_file): print(f'{md_file} not exists') success = False return md_content = open(md_file, 'r').read() if 'ee' in directory_file: md_content = re.sub(r'{% emqxce %}([\s\S]*?){% endemqxce %}', '', md_content) else: md_content = re.sub(r'{% emqxee %}([\s\S]*?){% endemqxee %}', '', md_content) image_list = re.findall('(.*?)!\[(.*?)\]\((.*?)\)', md_content) url_list = re.findall('(.*?)\[(.*?)\]\((.*?)\)', md_content) for url in url_list: if url[0].endswith('!'): continue if url[2].startswith(('http://', 'https://', '<', '#', 'mailto:')) or url[2].find('.md') == -1: continue url_path = url[2].split('.md')[0] ref_md_path = os.path.join(f'{"/".join(md_file.split("/")[:-1])}/', f'{url_path}.md') if not os.path.exists(ref_md_path): print(f'In {md_file}:', end='') print(f'{url[2]} not found or not in {directory_file}') success = False for image in image_list: if image[0].startswith('