Forráskód Böngészése

fix(action): fix directory_check.py

Signed-off-by: Swilder-M <poxiaobbs@gmail.com>
Swilder-M 3 éve
szülő
commit
83c5d0d7d8
1 módosított fájl, 7 hozzáadás és 4 törlés
  1. 7 4
      .github/workflows/directory_check.py

+ 7 - 4
.github/workflows/directory_check.py

@@ -23,15 +23,18 @@ def check_md_content(md_file):
         md_content = re.sub(r'{% emqxee %}([\s\S]*?){% endemqxee %}', '', md_content)
 
     image_list = re.findall('(.*?)!\[(.*?)\]\((.*?)\)', md_content)
-    url_list = re.findall('(.*?)\[(.*?)\]\((.*?).md(.*?)\)', md_content)
+    url_list = re.findall('(.*?)\[(.*?)\]\((.*?)\)', md_content)
     for url in url_list:
-        if url[2].startswith(('http://', 'https://', '<')):
+        if url[0].endswith('!'):
             continue
-        ref_md_path = os.path.join(f'{"/".join(md_file.split("/")[:-1])}/', f'{url[2]}.md')
+        if url[2].startswith(('http://', 'https://', '<', '#')):
+            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]}.md', f'not found or not in {directory_file}')
+            print(f'{url[2]} not found or not in {directory_file}')
             success = False
 
     for image in image_list: