(text)
| 9 | raw_url_pattern = re.compile(r'https?://\S+') |
| 10 | |
| 11 | def clean_footnotes(text): |
| 12 | if "**Footnotes**" not in text: |
| 13 | return text |
| 14 | |
| 15 | parts = text.split("**Footnotes**") |
| 16 | pre_footnotes = parts[0] |
| 17 | footnotes = parts[1] |
| 18 | |
| 19 | # Process footnotes line by line |
| 20 | cleaned_lines = [] |
| 21 | for line in footnotes.split('\n'): |
| 22 | # 1. Replace [text](url) with just text |
| 23 | line = markdown_link_pattern.sub(r'\1', line) |
| 24 | # 2. Remove raw URLs |
| 25 | line = raw_url_pattern.sub('', line) |
| 26 | |
| 27 | # strip excessive spaces that might have been left |
| 28 | line = line.replace(' :', ':').replace(' ,', ',').replace(' .', '.') |
| 29 | cleaned_lines.append(line) |
| 30 | |
| 31 | return pre_footnotes + "**Footnotes**" + '\n'.join(cleaned_lines) |
| 32 | |
| 33 | changed_files = 0 |
| 34 | for file_path in dir_path.glob("*.md"): |
no outgoing calls
no test coverage detected