X-Git-Url: http://unremediatedgender.space/source?p=Ultimately_Untrue_Thought.git;a=blobdiff_plain;f=notes%2Fpatriate_links.py;fp=notes%2Fpatriate_links.py;h=1781b75e979c2331c374e0235eb29a691fa3f335;hp=0000000000000000000000000000000000000000;hb=4ec03361902f5ccde1d52e1fff00782fddfcbc9a;hpb=905b82f7c6c4ab60d1b9a7f6bcf2332896c20915 diff --git a/notes/patriate_links.py b/notes/patriate_links.py new file mode 100755 index 0000000..1781b75 --- /dev/null +++ b/notes/patriate_links.py @@ -0,0 +1,31 @@ +#!/usr/bin/python3 + +import re +import sys + +# Python script to rewrite Markdown links and remove anchors +# mostly by GPT-4 + +# Define the path for the input and output files +input_file_path = sys.argv[1] +output_file_path = "out.md" + +# Define the regular expression patterns for Markdown links and anchors +markdown_link_pattern = re.compile(r'\]\(/(\d{4}/\w{3}/[-\w]+/)\)') +anchor_pattern = re.compile(r'') + +# Read the content of the original markdown file +with open(input_file_path, 'r') as file: + content = file.read() + +# Replace the Markdown links with the new format +rewritten_content = markdown_link_pattern.sub(r'](http://unremediatedgender.space/\1)', content) + +# Remove the anchors +rewritten_content = anchor_pattern.sub('', rewritten_content) + +# Write the rewritten content to a new file +with open(output_file_path, 'w') as file: + file.write(rewritten_content) + +print(f"rewritten markdown has been saved to {output_file_path}")