Skip to content

Commit

Permalink
fix: find existing badge
Browse files Browse the repository at this point in the history
  • Loading branch information
shenxianpeng committed Mar 15, 2024
1 parent 71f7d80 commit 2833792
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ used-by --repo shenxianpeng/used-by --doc-type rst
## Add Used By badge in README

Copy following content to show Used By badge in your repository README.

[![used-by](https://img.shields.io/static/v1?label=Used%20by&message=0&color=informational&logo=slickpic)](https://github.com/shenxianpeng/used-by/network/dependents) <!-- used by badge -->

**Markdown**
Expand Down
4 changes: 3 additions & 1 deletion used_by/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def generate_rst_badge(
def get_existing_badge(file_path) -> str:
with open(file_path) as file:
file_contents = file.read()
existing_badge = re.search(f"(.*?){COMMENT_MARKER}", file_contents, re.DOTALL)
existing_badge = re.search(
rf"\s(.*?){COMMENT_MARKER}", file_contents, re.DOTALL
)
return existing_badge.group(1).strip() if existing_badge else ""


Expand Down

0 comments on commit 2833792

Please sign in to comment.