Skip to content

Commit 4addc58

Browse files
authored
Update and rename update_recent.py to update-recent.py
1 parent 4c68980 commit 4addc58

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ def is_excluded(rel: str) -> bool:
3636
def is_included(rel: str) -> bool:
3737
return pathlib.Path(rel).suffix in INCLUDE_EXTS and not is_excluded(rel)
3838

39-
def recent_changed_files(limit: int) -> List[Tuple[str,str]]:
39+
def recent_changed_files(limit: int) -> List[Tuple[str, str]]:
4040
"""
4141
returns list of (date, relative_path) by most recent commit that touched each file.
4242
"""
43-
# --name-only 으로 전체 파일 히스토리를 시간 역순으로 쭉 받고, 한 파일당 가장 최신 등장만 채택
43+
# 전체 히스토리에서 파일 변경을 시간 역순으로 훑고, 파일당 가장 최신 등장만 채택
4444
log = sh("git", "log", "--name-only", "--pretty=format:%H|%cd", "--date=short", "--", ".")
4545
seen = set()
46-
items: List[Tuple[str,str]] = []
46+
items: List[Tuple[str, str]] = []
4747
for block in log.split("\n\n"):
4848
lines = [ln for ln in block.splitlines() if ln.strip()]
4949
if not lines or "|" not in lines[0]:
@@ -89,19 +89,21 @@ def platform_guess(rel: str) -> str:
8989
parts = pathlib.Path(rel).parts
9090
return parts[0] if parts else ""
9191

92-
def build_table(rows: List[Tuple[str,str]]) -> str:
92+
def build_table(rows: List[Tuple[str, str]]) -> str:
9393
if not rows:
9494
return "_최근 변경된 풀이 파일을 찾지 못했습니다._"
9595
lines = [
9696
"| 날짜 | 문제 | 위치 | 링크 |",
9797
"|---|---|---|---|",
9898
]
9999
for date, rel in rows:
100-
title = read_problem_title(ROOT / rel)
100+
# 제목에 | 가 있으면 표가 깨지므로 이스케이프
101+
title = read_problem_title(ROOT / rel).replace("|", r"\|")
101102
plat = platform_guess(rel)
102103
url = f"./{rel}"
104+
safe_url = f"<{url}>" # 공백/특수문자 포함 경로 안전 처리
103105
display_loc = plat if plat else "-"
104-
lines.append(f"| {date} | **{title}** | {display_loc} | [코드]({url}) |")
106+
lines.append(f"| {date} | **{title}** | {display_loc} | [코드]({safe_url}) |")
105107
return "\n".join(lines)
106108

107109
def replace_between(text: str, start_tag: str, end_tag: str, replacement: str) -> str:

0 commit comments

Comments
 (0)