Created
July 11, 2024 05:34
-
-
Save lumpenspace/fad4ab28b5ce25548da5d2394489b267 to your computer and use it in GitHub Desktop.
quickies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def midrashify(text): | |
footnotes = [] | |
footnote_count = 0 | |
def replace_with_footnote(match): | |
nonlocal footnote_count | |
footnote_count += 1 | |
content = match.group(1) | |
footnotes.append(content) | |
return f"[{footnote_count}]" | |
processed_text = re.sub(r'\(\(\((.*?)\)\)\)', replace_with_footnote, text) | |
if footnotes: | |
processed_text += "\n\nFootnotes:\n" | |
for i, note in enumerate(footnotes, 1): | |
processed_text += f"{i}. {note}\n" | |
return processed_text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment