Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include variables inline #800

Open
rmnldwg opened this issue Dec 6, 2023 · 4 comments
Open

Include variables inline #800

rmnldwg opened this issue Dec 6, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@rmnldwg
Copy link

rmnldwg commented Dec 6, 2023

Proposal

It would be great if one could include computational output - stored either in a Jupyter notebook or a separate file - inline and formatted just as normal text.

Additional notes

It is already really great to be able to include figures from a notebook in a scientific article when using MyST. However, what's missing for me is to include results or variables inline with normal text.

E.g., when I write a manuscript like this

## Methods

We included ![](#num-patients) patients in our study. Their mean age was ![](#mean-age) years.

an I have the corresponding notebook cells, then I see this:

image

But I would like to include these numbers like so:

image

I have seen that there is the substitutions syntax in the MyST parser. Could this be used here as well to include data stored e.g. in a variables.yaml file?

Another solution would be to allow inline references of just the output of a cell, rendered as if it were normal text.

Thanks for looking into this!

@rmnldwg rmnldwg added the enhancement New feature or request label Dec 6, 2023
Copy link

welcome bot commented Dec 6, 2023

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

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! 🎉

@agoose77
Copy link
Contributor

agoose77 commented Jan 10, 2024

In the MyST ecosystem we have a couple of mechanisms for this; the substitutions syntax, which is not implemented in our myst-spec (that governs "official" features), and the eval syntax. The eval role (although not referenced anywhere on mystmd.org yet) will evaluate the embedded code fragment in the active kernel, and embed the result.

To use eval roles, you need to execute the notebook with jupyterlab-myst, and save the notebook. In future, we'll have tooling to do this as part of a myst build.

In an executable notebook, you can use the eval role as follows:

The sum of 1 and 2 is {eval}`1 + 2`.

c.f. https://mystmd.org/guide/quickstart-jupyter-lab-myst#inline-expressions

@rmnldwg
Copy link
Author

rmnldwg commented Jan 16, 2024

Thanks for your comment!

I am happy to hear that the myst-cli will include tooling to execute code cells in the future.

The eval role in executable notebooks is really neat and I have used that in the past. But since code cells in jupyter notebooks cannot be hidden at the moment, I can either have code and output in my paper or neither, right?

So, to rephrase my problem slightly: I would love to have a way of rendering computational output (inline) without rendering the code that generated the output (either because it's hidden or because it lives somewhere else).

Though, if I understand this roadmap correctly, that will come soon in the form of code-cells that can be hidden (a.k.a. toggle).

Anyways, sounds like this will be implemented in some form or another 👍🏻

@choldgraf
Copy link
Collaborator

I looked through this issue and think it's actually a combination of several enhancement requests that could be tackled independently of one another, so I've opened up an issue for each:

Dos that sound correct to others? If so, could we close this issue in favor of those more precise follow-up issues?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants