-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchange_line_links.py
More file actions
39 lines (31 loc) · 919 Bytes
/
change_line_links.py
File metadata and controls
39 lines (31 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# %% GPT change_line_links
import sys
# %%
def rewrite_string_links(text):
# Replace " https:" with " \nhttps:"
rewritten_text = text.replace(' https:', ' \nhttps:')
# Replace " http:" with " \nhttp:"
rewritten_text = rewritten_text.replace(' http:', ' \nhttp:')
return rewritten_text
"""
################
test code
################
input_text = 'This is a https: example. Another http: example.'
rewritten_text = rewrite_string(input_text)
print(rewritten_text)
"""
# %%
def main(file_name):
with open(file_name) as f:
markdown_text = f.read()
# $ underscores $
replaced_text = rewrite_string_links(markdown_text)
# file name
# replaced_filename = replace_extension(file_name)
replaced_filename = file_name
with open(replaced_filename, 'w') as f:
f.write(replaced_text)
args = sys.argv
file_name = args[1]
main(file_name)