add ipynb to md conversion

This commit is contained in:
Jakub Pokrywka 2021-09-27 13:29:40 +02:00
parent ad34aaeae0
commit 4437a7f71b
3 changed files with 25 additions and 0 deletions

7
convert_ipynb_to_md.sh Normal file
View 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"

View 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
View File

@ -0,0 +1,5 @@
for i in {cw,wyk}/*.ipynb;
do
bash convert_ipynb_to_md.sh $i
echo $i done
done