-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotebook_to_md.command
More file actions
executable file
·36 lines (30 loc) · 1.17 KB
/
notebook_to_md.command
File metadata and controls
executable file
·36 lines (30 loc) · 1.17 KB
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
#!/bin/bash
cd "${BASH_SOURCE%/*}"
#
# # Copy all notebooks, and png files in an img folders.
rsync -rPz --include="*.ipynb" --include="*/img/*.png" --exclude="/notes/" --exclude="*.*" --delete-excluded rosles@gales.cs.ox.ac.uk:projects/crisis-data/notebooks/ notebooks/
# Remove empty directories (i.e. where contents were excluded)
find . -empty -type d -delete
# # Create Markdown copies of notebooks for Github viewing (No longer needed)
# rm -rf ./notebooks/markdown/*
# jupyter nbconvert --output-dir='./notebooks/markdown' --to markdown notebooks/*.ipynb
# cp -r ./notebooks/data ./notebooks/markdown/data
# Remove style tag contents from .md files as they do not render on Github:
# python3 <<EOF
# import os, re
# dir = './notebooks/markdown/'
# for fname in os.listdir(dir):
# if fname.split('.')[-1] != 'md':
# continue
# os.rename(dir + fname, dir + fname + '.orig')
# with open(dir + fname + '.orig', 'r') as fin, open(dir + fname, 'w') as fout:
# data = fin.read()
# data = re.sub(r'(\n\<style scoped\>).*?(style\>)',
# '',
# data, flags=re.DOTALL)
# fout.write(data)
# os.remove(dir + fname + '.orig')
# EOF
git add --all
git commit -m 'auto-commit'
git push