← All notes

Misc DONE

Inline notebook snippets — demo

Updated

For quick one-cell illustrations the full .ipynb embed is overkill. The {% nb_cell %} block tag renders an inline notebook-style cell, auto-numbered, with optional output.

Plain stdout

In [1]:
import numpy as np
print(np.array([1, 2, 3]).sum())
Out[1]:
6

Error / traceback

In [2]:
1 / 0
Out[2]:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: division by zero

Multiple outputs in one cell

Mix stdout, image, and HTML in the same cell — sentinels just stack:

In [3]:
import matplotlib.pyplot as plt
plt.plot([0, 1, 4, 9, 16, 25])
plt.show()
print("plotted squares")
Out[3]:
plotted squares
output

(The image sentinel takes a normal site path — drop your plot under images/ or assets/ and point at it.)

Different language

In [4]:
ls _notes/ | wc -l
Out[4]:
4

No prompt gutter (clean code snippet)

Pass no_prompt to drop the In[n]: / Out[n]: labels — useful when the prompt is visual noise:

def fuse(imu, lidar):
    return kalman_update(imu, lidar)
<kalman update result>

Reset counter

The In[n]/Out[n] counter auto-increments per page. To restart it (e.g., a new “session” within one note), drop:

{% nb_reset %}

Syntax reference

{% nb_cell <language>[, no_prompt] %}
<code>
---out
<plain text output>
---err
<error / stderr text>
---img <path>
---html
<raw html>
{% endnb_cell %}

Supported languages: python, bash, ruby, js, cpp, rust, go, r, julia. Unknown → falls back to python.

Use the full {% jupyter_notebook %} embed when you want a multi-cell .ipynb with real plots, dataframes, and LaTeX outputs. Use nb_cell for a quick illustration that lives in the note itself.