-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d8ad35f
commit 7af02c3
Showing
67 changed files
with
13,464 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
venv | ||
.venv | ||
.ipynb_checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
include: | ||
- dist | ||
- posts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os | ||
import subprocess | ||
import shutil | ||
|
||
# Directory containing .ipynb files | ||
input_dir = 'submissions' | ||
|
||
# Directory to save .md files | ||
output_dir = 'posts' | ||
|
||
# Directory to save images | ||
img_dir = os.path.join(output_dir, 'img') | ||
|
||
# Create the image directory if it doesn't exist | ||
os.makedirs(img_dir, exist_ok=True) | ||
|
||
# Get list of all .ipynb files in input_dir | ||
ipynb_files = [f for f in os.listdir(input_dir) if f.endswith('.ipynb')] | ||
|
||
# Iterate over .ipynb files and convert each one | ||
for ipynb_file in ipynb_files: | ||
# Construct full file paths | ||
input_file = os.path.join(input_dir, ipynb_file) | ||
# Remove .ipynb extension and add .md extension | ||
output_file = os.path.join(output_dir, ipynb_file.rsplit('.', 1)[0] + '.md') | ||
|
||
# Run nbconvert command | ||
subprocess.run(['jupyter', 'nbconvert', '--to', 'markdown', input_file, '--output-dir', output_dir]) | ||
|
||
# Move the image folder to img | ||
image_folder = os.path.join(output_dir, ipynb_file.rsplit('.', 1)[0] + '_files') | ||
if os.path.exists(image_folder): | ||
new_image_folder = os.path.join(img_dir, ipynb_file.rsplit('.', 1)[0] + '_files') | ||
shutil.move(image_folder, new_image_folder) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.