forked from filipg/aitech-eks-pub
add ipynb to md conversion
This commit is contained in:
parent
ad34aaeae0
commit
4437a7f71b
7
convert_ipynb_to_md.sh
Normal file
7
convert_ipynb_to_md.sh
Normal file
@ -0,0 +1,7 @@
|
||||
set -ex
|
||||
|
||||
FILEIPYNB=$1
|
||||
jupyter nbconvert --to script $1
|
||||
FILEPY=$(echo $FILEIPYNB | sed 's/.ipynb$/.py/')
|
||||
FILEMD=$(echo $FILEIPYNB | sed 's/.ipynb$/.md/')
|
||||
python convert_python_to_markdown.py "$FILEPY" "$FILEMD"
|
13
convert_python_to_markdown.py
Normal file
13
convert_python_to_markdown.py
Normal file
@ -0,0 +1,13 @@
|
||||
import sys
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
from markdown import markdown
|
||||
|
||||
with open(sys.argv[1]) as f_in, open(sys.argv[2],'w') as f_out:
|
||||
for i, line in enumerate(f_in):
|
||||
if i in (1,2):
|
||||
continue
|
||||
if line[:2] == "# " and line[:5] != "# In[":
|
||||
text = line[:2]
|
||||
f_out.write(line[2:])
|
||||
|
5
run_conversion.sh
Normal file
5
run_conversion.sh
Normal file
@ -0,0 +1,5 @@
|
||||
for i in {cw,wyk}/*.ipynb;
|
||||
do
|
||||
bash convert_ipynb_to_md.sh $i
|
||||
echo $i done
|
||||
done
|
Loading…
Reference in New Issue
Block a user