Skip to content

Commit 3756945

Browse files
style: fixed formatting issues
1 parent e3950aa commit 3756945

3 files changed

Lines changed: 15 additions & 11 deletions

File tree

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"cSpell.words": ["opendocument", "pandoc"]
3+
}

src/docx_to_markdown.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,10 @@ def convert_files(args):
113113

114114
out_file_path = os.path.join(file_dir, filename + ".md")
115115

116-
# docx_to_md(args, docx_file, out_file_path, file_dir)
117-
# extract_embedded_files(docx_file, file_dir)
118-
# add_embedded_file_content(out_file_path, file_dir)
119-
# remove_done_file(filename, os.path.dirname(docx_file))
116+
docx_to_md(args, docx_file, out_file_path, file_dir)
117+
extract_embedded_files(docx_file, file_dir)
118+
add_embedded_file_content(out_file_path, file_dir)
119+
remove_done_file(filename, os.path.dirname(docx_file))
120120
if args.gen_contents:
121121
gen_contents(args)
122122

@@ -223,8 +223,8 @@ def add_embedded_file_content(out_file_path, file_dir):
223223
odt_text = Markdown_Formatter.format_tabs(odt_text)
224224
language = "text"
225225

226-
# Get the odt number and check if it is in the matches. If it is, replace
227-
# the match with the odt text
226+
# Get the odt number and check if it is in the matches. If it is,
227+
# replace the match with the odt text
228228
odt_file_name = os.path.basename(odt_file).split(".")[0]
229229
odt_num = odt_file_name.split("-")[1]
230230

@@ -260,7 +260,7 @@ def remove_done_file(filename, input_dir):
260260
def gen_contents(args):
261261
print("Generating contents.md...")
262262
path = chdir()
263-
conents_path = os.path.abspath(os.path.join(args.out_directory, "README.md"))
263+
contents_path = os.path.abspath(os.path.join(args.out_directory, "README.md"))
264264
notes_category = {}
265265
for root, _, files in os.walk(args.out_directory):
266266
for file in files:
@@ -271,7 +271,7 @@ def gen_contents(args):
271271
else:
272272
notes_category[category].append(os.path.join(root, file))
273273

274-
with open(conents_path, "w") as contents_file:
274+
with open(contents_path, "w") as contents_file:
275275
contents_file.write("# Table of Contents\n\n")
276276
for category in sorted(notes_category.keys()):
277277
contents_file.write(f"\n## {category}\n\n")
@@ -287,7 +287,8 @@ def gen_contents(args):
287287
readme_path = os.path.abspath(os.path.join(path, "..", "README.md"))
288288
with open(readme_path, "r") as readme_file:
289289
readme_content = readme_file.read()
290-
# find and delete the text between the ## Table of Contents and the ## Disclaimer
290+
# find and delete the text between the ## Table of Contents and the
291+
# ## Disclaimer
291292
table_of_contents = re.search(
292293
r"## Table of Contents(.*\n)+## Disclaimer", readme_content
293294
)

src/formatter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ def format_images(text):
116116

117117
@staticmethod
118118
def format_cover_page(text):
119-
pattern = r"\+.*\n.*>\s*(.*\w).*\|\n.*\n.*\n.*\n.*>\s*(.*\w).*\|\n.*\n.*>\s*(.*\w).*\|\n.*\n.*>\s*(.*\d).*\|\n.*\+"
119+
pattern = r"\+.*\n.*>\s*(.*\w).*\|\n.*\n.*\n.*\n.*>\s*(.*\w).*\|\n.*\n.*>\s*(.*\w).*\|\n.*\n.*>\s*(.*\d).*\|\n.*\+" # noqa: E501
120120
text = re.sub(pattern, r"# \1\n\n@ \2\n@ \3\n@ \4\n", text)
121121
text = text.replace("\n\n\n: Cover page info", "")
122122
return text
123123

124124
@staticmethod
125125
def remove_format_table(text):
126-
pattern = r"\nThese notes use a range of different formatting for different purposes.\nThe following is each format and their purpose:\n\n\+(?:.*\n){15}.*\+\n"
126+
pattern = r"\nThese notes use a range of different formatting for different purposes.\nThe following is each format and their purpose:\n\n\+(?:.*\n){15}.*\+\n" # noqa: E501
127127
text = re.sub(pattern, "", text)
128128
return text
129129

0 commit comments

Comments
 (0)