|
7 | 7 | from leetcode_export._version import __version__ |
8 | 8 | from leetcode_export.leetcode import LeetCode |
9 | 9 |
|
10 | | -PROBLEM_CONTENT_TEMPLATE = Template('''${question_id} - ${title} |
11 | | -${difficulty} - https://leetcode.com/problems/${title_slug}/ |
12 | | -
|
13 | | -${content} |
14 | | -''') |
15 | | - |
16 | 10 |
|
17 | 11 | def parse_args(): |
18 | 12 | parser = argparse.ArgumentParser(description='Export LeetCode solutions') |
19 | 13 | parser.add_argument('--cookies', type=str, help='set LeetCode cookies') |
20 | 14 | parser.add_argument('--folder', type=str, default='.', help='set output folder') |
21 | | - parser.add_argument('--problem-filename', type=str, default='${question_id} - ${title_slug}.txt', |
| 15 | + parser.add_argument('--problem-filename', type=str, default='${question_id} - ${title_slug}.html', |
22 | 16 | help='problem description filename format') |
| 17 | + parser.add_argument('--problem-content', type=str, |
| 18 | + default='<h1>${question_id} - ${title}</h1><h2>Difficulty: ${difficulty} - ' + |
| 19 | + '<a href="https://leetcode.com/problems/${title_slug}/">${title_slug}</a></h2>${content}', |
| 20 | + help='problem description content format') |
23 | 21 | parser.add_argument('--submission-filename', type=str, |
24 | 22 | default='${date_formatted} - ${status_display} - runtime ${runtime} - memory ${memory}.${extension}', |
25 | 23 | help='submission filename format') |
@@ -53,6 +51,7 @@ def main(): |
53 | 51 | ) |
54 | 52 |
|
55 | 53 | problem_template = Template(args.problem_filename) |
| 54 | + problem_content_template = Template(args.problem_content) |
56 | 55 | submission_template = Template(args.submission_filename) |
57 | 56 |
|
58 | 57 | leetcode = LeetCode() |
@@ -83,7 +82,7 @@ def main(): |
83 | 82 | info_filename = problem_template.substitute(**problem.__dict__) |
84 | 83 | if not os.path.exists(info_filename): |
85 | 84 | info_file = open(info_filename, 'w+') |
86 | | - info_file.write(PROBLEM_CONTENT_TEMPLATE.substitute(**problem.__dict__)) |
| 85 | + info_file.write(problem_content_template.substitute(**problem.__dict__)) |
87 | 86 | info_file.close() |
88 | 87 | written_problems.add(submission.title_slug) |
89 | 88 |
|
|
0 commit comments