jupyter-book
jupyter-book copied to clipboard
Better inline eval tutorial.
Context
First, I think it's necessary to put this somewhere prominent in the tutorial. Tell the reader that if they want to inline a reference, they need to put this in the yaml. It took me an hour of searching just to notice that this is what we need.
mystnb:
execution_mode: 'inline'
Considering that I switched to Jupyter Book specifically because I couldn't deal with the lack of inline reference in Jupyter Lab, and found Jupyter Book because of this pointer in https://discourse.jupyter.org/t/inline-variable-insertion-in-markdown/10525 , this feature really should be shown in the tutorial, perhaps putting this segment specifically into the "getting started" default project.
Next let's try some inline text reference.
```{code-cell}
def fibb(n):
a, b = 0, 1
for i in range(n):
a, b = b, a + b
return a
print(fibb(10))
fibb10 = fibb(10)
```
The 10th Fibonacci number is {eval}`fibb10`.
I also feel like it would be good if I can use inline evals, like instead of defining a temporary variable just to insert it into text, I would like it to be evaluated right at the point.
For example, it'd be cool if I can do this instead:
The 10th Fibonacci number is {eval}`fibb(10)`.
Proposal
No response
Tasks and updates
No response
Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:
Hi @yuxiliu1995, thanks for the feedback! Yes, we could make that aspect more obvious. We probably should error if we encounter evals in a non-Eval context.
We have added support for more general expressions, hidden behind a config flag. It will be released in the next version of myst-nb, which is coming soon.