Skip to content

Commit f7c48c2

Browse files
committed
Added conversion to .ipynb from .md
1 parent 9b0cc60 commit f7c48c2

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

Dockerfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
ARG BASE_CONTAINER=tlinnet/csharp-notebook
22
FROM $BASE_CONTAINER
33

4+
USER root
5+
6+
ADD "README.md" $HOME
47
ADD "Example_Jupyter_Notebook_with_C#.ipynb" $HOME
58
ADD Exam_Ref_70-483_Programming_in_C#_2nd_Edition $HOME/Exam_Ref_70-483_Programming_in_C#_2nd_Edition
9+
10+
ADD "dev/convert_md_to_ipynb.py" $HOME/dev/convert_md_to_ipynb.py
11+
RUN echo "Change mod and convert" && \
12+
cd $HOME && \
13+
echo $PWD && \
14+
fix-permissions README.md && \
15+
fix-permissions Exam_Ref_70-483_Programming_in_C#_2nd_Edition && \
16+
cd $HOME/dev && \
17+
python convert_md_to_ipynb.py && \
18+
cd $HOME && \
19+
rm -rf dev && \
20+
find . -type f -name "*.md" -exec rm -f {} \;
21+
22+
USER $NB_USER

dev/convert_md_to_ipynb.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import glob
2+
import os
3+
import nbformat as nbf
4+
5+
files1 = glob.glob('../*.md', recursive=True)
6+
files2 = glob.glob('../*/*.md', recursive=True)
7+
8+
files = files1 + files2
9+
10+
for f in files:
11+
fname = f[:-3]
12+
13+
nb = nbf.v4.new_notebook()
14+
s = open(f, "r").read()
15+
s = s.replace(".md", ".ipynb")
16+
nb['cells'].append(nbf.v4.new_markdown_cell(s))
17+
nbf.write(nb, fname+".ipynb")

0 commit comments

Comments
 (0)