Skip to content

Commit

Permalink
バッククウォートに対応
Browse files Browse the repository at this point in the history
  • Loading branch information
YusukeKato committed Sep 22, 2024
1 parent 7e983bc commit 1aee845
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scripts/md2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
import re
version="1002"

def replace_strong(str):
strong_flag = True
for i in range(len(str)):
if str[i] == '`' and strong_flag:
str[:i] + '<strong>' + str[i:]
strong_flag = False
elif str[i] == '`' and not strong_flag:
str[:i] + '</strong>' + str[i:]
strong_flag = True
return str

# markdownのファイル名を全て取得
markdown_files = []
with open('./markdown_list.txt', 'r', encoding='UTF-8') as fr:
Expand Down Expand Up @@ -202,7 +213,7 @@
write_lines.append('</div>\n')
i += 2
else: # 文章を変換
write_lines.append('<p>' + read_lines[i] + '\n')
write_lines.append('<p>' + replace_strong(read_lines[i]) + '\n')
p_loop_flag = True;
while p_loop_flag:
i += 1
Expand All @@ -211,7 +222,7 @@
elif read_lines[i] == '':
p_loop_flag = False
else:
write_lines.append(read_lines[i] + '\n')
write_lines.append(replace_strong(read_lines[i]) + '\n')
write_lines.append('</p>\n')

# お知らせ生成
Expand Down

0 comments on commit 1aee845

Please sign in to comment.