Skip to content

Commit

Permalink
修正链接转换错误
Browse files Browse the repository at this point in the history
  • Loading branch information
kagangtuya-star committed Dec 18, 2023
1 parent b3fc33a commit 0c99626
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion markdown2bbscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ def markdown_to_bbscode(markdown_text):
markdown_text = re.sub(r'^\d+\. (.*)$', '[list type=decimal]\n[li]\\1[/li]\n[/list]', markdown_text,
flags=re.MULTILINE)
# 将各种 Markdown 语法转换为对应的 BBSCode 标签
markdown_text = re.sub(r'!\[(.*?)\]\((.*?)\)', '[img]\\2[/img]', markdown_text)
markdown_text = re.sub(r'\[(.*?)\]\((.*?)\)', '[url=\\2]\\1[/url]', markdown_text)
markdown_text = re.sub(r'^# (.*)$', '[size=6][b]\\1[/b][/size]\n', markdown_text, flags=re.MULTILINE)
markdown_text = re.sub(r'^## (.*)$', '[size=5][b]\\1[/b][/size]\n', markdown_text, flags=re.MULTILINE)
markdown_text = re.sub(r'^### (.*)$', '[size=4][b]\\1[/b][/size]\n', markdown_text, flags=re.MULTILINE)
Expand All @@ -32,7 +34,6 @@ def markdown_to_bbscode(markdown_text):
markdown_text = re.sub(r'~~(.*?)~~', '[s]\\1[/s]', markdown_text)
markdown_text = re.sub(r'```([^`]*)```', '[code]\\1[/code]', markdown_text)
markdown_text = re.sub(r'\n\*\s(.*)$', '[*] \\1', markdown_text, flags=re.MULTILINE)
markdown_text = re.sub(r'<(https?://.*?)>', '[url]\\1[/url]', markdown_text)
markdown_text = re.sub(r'!\[(.*?)\]\((.*?)\)', '[img]\\2[/img]', markdown_text)
markdown_text = re.sub(r'\n-{3,}', '\n[hr]', markdown_text)

Expand Down

0 comments on commit 0c99626

Please sign in to comment.