-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathana.py
33 lines (27 loc) · 1.09 KB
/
ana.py
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
def extract_markdown_definitions(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
lines = file.readlines()
definitions = []
for line in lines:
# Strip leading and trailing whitespace
stripped_line = line.strip()
# Check if the line starts with '>'
if stripped_line.startswith('>'):
if len(stripped_line) == 1:
continue
definitions.append(stripped_line[1:].strip()) # Remove '>' and leading whitespace
#definitions.append('\n')
return definitions
def main():
# Replace 'your_file.md' with the path to your Markdown file
file_path = r'season-01\06 The One With the Butt\index.md'
definitions = extract_markdown_definitions(file_path)
# Write the extracted definitions to Vocabulary.txt
count = 0
with open('Vocabulary.txt', 'w', encoding='utf-8') as output_file:
for definition in definitions:
count += 1
output_file.write(str(count) + '. ' + definition + '\n\n')
print("success")
if __name__ == "__main__":
main()