-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import glob | ||
|
||
### | ||
# File: /add_ctexart_comment.py | ||
# Created Date: Monday, June 17th 2024 | ||
# Author: Zihan | ||
# ----- | ||
# Last Modified: Monday, 17th June 2024 4:31:23 pm | ||
# Modified By: the developer formerly known as Zihan at <[email protected]> | ||
# ----- | ||
# HISTORY: | ||
# Date By Comments | ||
# ---------- ------ --------------------------------------------------------- | ||
### | ||
|
||
# Find all Markdown files recursively | ||
md_files = glob.glob('**/*.md', recursive=True) | ||
|
||
# Comment to be added | ||
comment = '''--- | ||
toc: true | ||
documentclass: "ctexart" | ||
classoption: "UTF8" | ||
--- | ||
''' | ||
|
||
# Add the comment to each file | ||
for file in md_files: | ||
with open(file, 'r+') as f: | ||
content = f.read() | ||
f.seek(0, 0) | ||
f.write(comment + content) | ||
|
||
# delete first blank lines | ||
# for file in md_files: | ||
# with open(file, 'r+') as f: | ||
# content = f.readlines() | ||
# f.seek(0, 0) | ||
# for line in content: | ||
# if line.strip() != '': | ||
# f.write(line) | ||
# f.truncate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters