add
This commit is contained in:
46
format_text/journal/formatter_cloud.py
Normal file
46
format_text/journal/formatter_cloud.py
Normal file
@@ -0,0 +1,46 @@
|
||||
import os
|
||||
|
||||
|
||||
def format_md_file(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
content = file.read()
|
||||
|
||||
# 去#
|
||||
content = content.replace('# ', '')
|
||||
content = content.replace('#', '')
|
||||
# 将;转为句号
|
||||
content = content.replace(';', '。')
|
||||
# 将;转为句号
|
||||
content = content.replace(';', '。')
|
||||
# 将.转为句号
|
||||
content = content.replace('.', '。')
|
||||
# 将(转为(
|
||||
content = content.replace('(', '(')
|
||||
# 将)转为)
|
||||
content = content.replace(')', ')')
|
||||
# 将?转为?
|
||||
content = content.replace('?', '?')
|
||||
# 将,转为,
|
||||
content = content.replace(',', ',')
|
||||
# 将:转为:
|
||||
content = content.replace(':', ':')
|
||||
# 将 日星期 转为:日 星期
|
||||
content = content.replace('日星期', '日 星期')
|
||||
# 在第一行插入 #
|
||||
content = '# ' + content
|
||||
# 标题设置
|
||||
content = content.replace('一、生活方面', '## 一、生活方面')
|
||||
content = content.replace('二、交易方面', '## 二、交易方面')
|
||||
content = content.replace('三、工作方面', '## 三、工作方面')
|
||||
|
||||
with open(file_path, 'w', encoding='utf-8') as file:
|
||||
file.write(content)
|
||||
|
||||
if __name__ == "__main__":
|
||||
current_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
print(current_dir)
|
||||
for root, dirs, files in os.walk(current_dir):
|
||||
for file in files:
|
||||
if file.endswith('.md'):
|
||||
file_path = os.path.join(root, file)
|
||||
format_md_file(file_path)
|
||||
Reference in New Issue
Block a user