29 |
30 | parse:
31 | # myst_extended_syntax: true # instead enable individual features below
32 | myst_enable_extensions: # https://myst-parser.readthedocs.io/en/latest/using/syntax-optional.html
33 | - amsmath
34 | # - attrs_inline # causing the conflict with dollarmath
35 | - colon_fence
36 | - deflist
37 | - dollarmath
38 | - fieldlist
39 | - html_admonition
40 | - html_image
41 | - linkify
42 | - replacements
43 | - smartquotes
44 | - strikethrough
45 | - substitution
46 | - tasklist
47 |
48 | sphinx:
49 | config:
50 | mathjax_path: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
51 | mathjax_config:
52 | tex2jax:
53 | inlineMath: [["$","$"], ["\\(", "\\)"]]
54 | myst_update_mathjax: false
55 |
--------------------------------------------------------------------------------
/jb/_toc.yml:
--------------------------------------------------------------------------------
1 | format: jb-book
2 | root: index
3 | parts:
4 | - caption: Front Matter
5 | chapters:
6 | - file: chap00
7 | - caption: Chapters
8 | numbered: True
9 | chapters:
10 | - file: chap01
11 | - file: chap02
12 | - file: chap03
13 | - file: chap04
14 | - file: chap05
15 | - file: chap06
16 | - file: chap07
17 | - file: chap08
18 | - file: chap09
19 | - file: chap10
20 | - file: chap11
21 | - file: chap12
22 | - file: chap13
23 | - file: chap14
24 | - file: chap15
25 | - file: chap16
26 | - file: chap17
27 | - file: chap18
28 | - file: chap19
29 | - caption: End Matter
30 | chapters:
31 | - file: blank
32 |
--------------------------------------------------------------------------------
/jb/build.sh:
--------------------------------------------------------------------------------
1 | # pip install jupyter-book ghp-import
2 |
3 | # Build the Jupyter book version
4 |
5 | # copy the notebooks
6 | cp ../ThinkPythonSolutions/soln/chap[01][0-9]*.ipynb .
7 |
8 | # add tags to hide the solutions
9 | python prep_notebooks.py
10 |
11 | # build the HTML version
12 | jb build .
13 |
14 | # push it to GitHub
15 | ghp-import -n -p -f _build/html
16 |
--------------------------------------------------------------------------------
/jb/prep_notebooks.py:
--------------------------------------------------------------------------------
1 | import nbformat as nbf
2 | from glob import glob
3 |
4 |
5 | def process_cell(cell):
6 | # get tags
7 | tags = cell['metadata'].get('tags', [])
8 |
9 | # add hide-cell tag to solutions
10 | if cell['cell_type'] == 'code':
11 | source = cell['source']
12 |
13 | # remove solutions
14 | if source.startswith('# Solution') or 'solution' in tags:
15 | cell['source'] = []
16 |
17 | # remove %%expect cell magic
18 | if source.startswith('%%expect'):
19 | t = source.split('\n')[1:]
20 | cell['source'] = '\n'.join(t)
21 |
22 | # add reference label
23 | for tag in tags:
24 | if tag.startswith('chapter') or tag.startswith('section'):
25 | # print(tag)
26 | label = f'({tag})=\n'
27 | cell['source'] = label + cell['source']
28 |
29 |
30 | def process_notebook(path):
31 | ntbk = nbf.read(path, nbf.NO_CONVERT)
32 |
33 | for cell in ntbk.cells:
34 | process_cell(cell)
35 |
36 | nbf.write(ntbk, path)
37 |
38 |
39 | # Collect a list of the notebooks in the content folder
40 | paths = glob("chap*.ipynb")
41 |
42 | for path in sorted(paths):
43 | print('prepping', path)
44 | process_notebook(path)
45 |
--------------------------------------------------------------------------------
/jupyturtle_flower.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllenDowney/ThinkPython/38462ce925df86fb8015cc1e0c4873f5e237f9b2/jupyturtle_flower.png
--------------------------------------------------------------------------------
/jupyturtle_pie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AllenDowney/ThinkPython/38462ce925df86fb8015cc1e0c4873f5e237f9b2/jupyturtle_pie.png
--------------------------------------------------------------------------------
/jupyturtle_pie.svg:
--------------------------------------------------------------------------------
1 |