question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

code-cell inside a "special block" in a markdown cell of Jupyter Notebook

See original GitHub issue

I tried to execute a code inside a “special block” in a markdown cell in Jupyter Notebook:

````{tip}
Here is a sentence.
```{code-cell} python3
z = 100
```
Here is another sentence.
````

It generates an error:

WARNING: Unknown directive type "code-cell".

Is it an expected result?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
spring-harucommented, Jun 10, 2020

The following worked!

Place the following in a markdown cell:

````{tip}
Here is a sentence.
```python
print("Hello World!")
```
{glue:}`glued_txt`
````

Place the following in a code cell with a tag remove-cell:

from myst_nb import glue
my_variable = "Hello World!"
glue("glued_txt", my_variable)
1reaction
choldgrafcommented, Jun 9, 2020

ahhh right! I missed that part of your explanation, good point 👍

maybe we can add an extra section here: https://jupyterbook.org/content/content-blocks.html#notes-warnings-and-other-admonitions like “how to insert code outputs into your admonition blocks” and show a short example, then cross-link to the glue docs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Markdown Cells — Jupyter Notebook 6.5.2 documentation
Markdown basics . You can make text italic or bold by surrounding a block of text with a single or double *...
Read more >
Code and Markdown Cells in Jupyter Notebook - Earth Lab
Run Code and Markdown cells within Jupyter Notebook to execute Python code and render Markdown text. List useful shortcuts for common tasks ...
Read more >
Special content blocks - Jupyter Book
Blocks of text with custom titles# · Markdown-friendly directives with ::: # · Insert code cell outputs into admonitions# · HTML admonitions# ·...
Read more >
How to Embed Code or Code Block Inside Markdown Cell
how to embed code or code block inside markdown cell : - Here we have embeded code and codeblock inside markdown cell for...
Read more >
How To Write Code In Markdown Jupyter Notebook
First, open up your jupyter notebook and create a new file. ... Jupyter Notebook Markdown Code Block is a code cell type that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found