projects
/
Ultimately_Untrue_Thought.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
pt. 4 edits from an incomplete day
[Ultimately_Untrue_Thought.git]
/
notes
/
patriate_links.py
diff --git
a/notes/patriate_links.py
b/notes/patriate_links.py
index
3cc6ee7
..
c1f23cc
100755
(executable)
--- a/
notes/patriate_links.py
+++ b/
notes/patriate_links.py
@@
-11,10
+11,10
@@
input_file_path = sys.argv[1]
output_file_path = "out.md"
# Define the regular expression patterns for Markdown links and anchors
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]+/)\)')
+relative_link_pattern = re.compile(r'\]\(/(\d{4}/\w{3}/[-\w]+/)(#[-\w]+)?\)')
+relative_image_link_pattern = re.compile(r'\]\((/images/[-\w./]+)\)')
anchor_pattern = re.compile(r'<a id="[-\w]+"></a>')
anchor_pattern = re.compile(r'<a id="[-\w]+"></a>')
-# TODO: don't neglect links with #-section
# TODO: don't neglect images
# Read the content of the original markdown file
# TODO: don't neglect images
# Read the content of the original markdown file
@@
-22,7
+22,8
@@
with open(input_file_path, 'r') as file:
content = file.read()
# Replace the Markdown links with the new format
content = file.read()
# Replace the Markdown links with the new format
-rewritten_content = markdown_link_pattern.sub(r'](http://unremediatedgender.space/\1)', content)
+rewritten_content = relative_link_pattern.sub(r'](http://unremediatedgender.space/\1)', content)
+rewritten_content = relative_image_link_pattern.sub(r'](http://unremediatedgender.space/\1)', rewritten_content)
# Remove the anchors
rewritten_content = anchor_pattern.sub('', rewritten_content)
# Remove the anchors
rewritten_content = anchor_pattern.sub('', rewritten_content)