mirror of
https://github.com/TeachBooks/template.git
synced 2026-11-13 06:35:52 +00:00
massive transfer of risk-reliability book
This commit is contained in:
parent
6697c0f5f8
commit
3d24a01439
152 changed files with 57886 additions and 0 deletions
49
book/other-topics/test_codeblocks.md
Normal file
49
book/other-topics/test_codeblocks.md
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# Including a code block and a figure
|
||||
|
||||
Here is a code block that is parsed from a python file:
|
||||
|
||||
```{eval-rst}
|
||||
.. literalinclude:: ../code/sinewave.py
|
||||
:language: python
|
||||
```
|
||||
|
||||
Which is the result of:
|
||||
|
||||
```{eval-rst}
|
||||
.. literalinclude:: sinewave.py
|
||||
:language: python
|
||||
```
|
||||
|
||||
We can toggle the code block by nesting it inside a `toggle` directive:
|
||||
|
||||
```{toggle}
|
||||
```{eval-rst}
|
||||
.. literalinclude:: sinewave.py
|
||||
:language: python
|
||||
```
|
||||
|
||||
Note the single `-triplet at the end of the toggle.
|
||||
|
||||
````{toggle}
|
||||
```{eval-rst}
|
||||
.. literalinclude:: ../code/sinewave.py
|
||||
:language: python
|
||||
```
|
||||
````
|
||||
|
||||
The Python file saves the figure, so we can include it using the regular markdown recipe:
|
||||
|
||||
|
||||
```{figure} ../figures/sinewave.svg
|
||||
---
|
||||
name: sine_wave
|
||||
---
|
||||
A sine wave
|
||||
```
|
||||
|
||||
```{figure} ../figures/cosinewave.svg
|
||||
---
|
||||
name: cosine_wave
|
||||
---
|
||||
A cosine wave
|
||||
```
|
||||
Loading…
Add table
Add a link
Reference in a new issue