6 # Python script to rewrite Markdown links and remove anchors
9 # Define the path for the input and output files
10 input_file_path = sys.argv[1]
11 output_file_path = "out.md"
13 # Define the regular expression patterns for Markdown links and anchors
14 markdown_link_pattern = re.compile(r'\]\(/(\d{4}/\w{3}/[-\w]+/)\)')
15 anchor_pattern = re.compile(r'<a id="[-\w]+"></a>')
17 # Read the content of the original markdown file
18 with open(input_file_path, 'r') as file:
21 # Replace the Markdown links with the new format
22 rewritten_content = markdown_link_pattern.sub(r'](http://unremediatedgender.space/\1)', content)
25 rewritten_content = anchor_pattern.sub('', rewritten_content)
27 # Write the rewritten content to a new file
28 with open(output_file_path, 'w') as file:
29 file.write(rewritten_content)
31 print(f"rewritten markdown has been saved to {output_file_path}")