Skip to content

Commit

Permalink
feat: add autocorrect handling for badge divs
Browse files Browse the repository at this point in the history
  • Loading branch information
kowyo committed Nov 1, 2024
1 parent 125126b commit dcfdeb6
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/wrap_badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,25 @@ def wrap_badges_with_div(content, div_classes="img-div hx-mt-4 hx-flex-row hx-ju
i = 0
while i < len(lines):
# 如果当前行已经在div中,直接添加
if '<div class="img-div' in lines[i]:
if '<div class="img-div' in lines[i] and '<!-- autocorrect-disable -->' in lines[i-2]:
while i < len(lines) and '</div>' not in lines[i]:
processed_lines.append(lines[i])
i += 1
if i < len(lines):
processed_lines.append(lines[i]) # 添加结束的</div>
i += 1
continue
elif '<div class="img-div' in lines[i]:
# add a comment to prevent autocorrection
processed_lines.append('<!-- autocorrect-disable -->\n')
while i < len(lines) and '</div>' not in lines[i]:
processed_lines.append(lines[i])
i += 1
if i < len(lines):
processed_lines.append(lines[i]) # 添加结束的</div>
i += 1
processed_lines.append('\n<!-- autocorrect-enable -->\n')
continue

# 检查是否是badge行
if re.search(badge_pattern, lines[i]):
Expand Down

0 comments on commit dcfdeb6

Please sign in to comment.