remove duplication in first line
This commit is contained in:
parent
158e9072e4
commit
56cefc63c6
|
|
@ -59,11 +59,13 @@ def remove_extra_parentheses(lines):
|
||||||
|
|
||||||
def add_awesome_badge(lines):
|
def add_awesome_badge(lines):
|
||||||
"""Ensure the Awesome badge is correctly added."""
|
"""Ensure the Awesome badge is correctly added."""
|
||||||
badge = '[](https://awesome.re)'
|
# Check for an existing "Awesome" badge in the lines
|
||||||
# Check if the badge already exists
|
for line in lines:
|
||||||
if any(badge in line for line in lines):
|
if "https://awesome.re" in line:
|
||||||
return lines
|
return lines # Badge already exists; do nothing
|
||||||
|
|
||||||
# Add the badge at the top if not present
|
# Add the badge at the top if not present
|
||||||
|
badge = '[](https://awesome.re)'
|
||||||
lines.insert(0, badge)
|
lines.insert(0, badge)
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
|
@ -83,10 +85,11 @@ def remove_duplicate_links(lines):
|
||||||
seen_links = set()
|
seen_links = set()
|
||||||
deduplicated_lines = []
|
deduplicated_lines = []
|
||||||
for line in lines:
|
for line in lines:
|
||||||
|
# Check for links in the current line
|
||||||
if match := re.search(r'\((https?://[^\)]+)\)', line):
|
if match := re.search(r'\((https?://[^\)]+)\)', line):
|
||||||
link = match.group(1)
|
link = match.group(1)
|
||||||
if link in seen_links:
|
if link in seen_links and "https://awesome.re" not in line:
|
||||||
continue # Skip duplicate link
|
continue # Skip duplicate links (but don't remove Awesome badge)
|
||||||
seen_links.add(link)
|
seen_links.add(link)
|
||||||
deduplicated_lines.append(line)
|
deduplicated_lines.append(line)
|
||||||
return deduplicated_lines
|
return deduplicated_lines
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue