Showing pseudocode in the Notebook

I have a question of how you present pseudocode in the Notebook, particularly in MarkDown cells. One option is to create an (SVG) image and render it in the cell, but maybe somebody has found a workaround.

What is the issue with what you get when you put it between triple ticks just like you’d do with real code in markdown like below?

This is pseudocode
   More pseudocode here

I used text as the ‘language’ after first set of triple ticks in block above.
More information on fenced code blocks here.

Alternatively, you could use HTML to custom color text in the markdown.

The thing is that using text as “language” does not highlight any keywords. So the questions is more about what other users are doing for pseudocode … although there is not standard for it, so it might be difficult.

You can use the language that is closest to what you want your pseudocode to be like, perhaps?

Or custom color the text via HTML in the markdown cell. You can add shading too, so you can make the block look like code blocks of other markdown renderings, too.
For example place the code block below in a markdown cell in Jupyter to add custom coloring and shading to the example block like I used above.

<div style="background-color:rgba(0, 0, 0, 0.0470588); padding:10px 0;font-family:monospace;">
This is <font color = "red">pseudocode</font><br>
&nbsp;&nbsp;&nbsp;&nbsp; More pseudocode <font color = "orange" over</font> there.
1 Like

I think that the HTML snippet of yours is a good workaround, thanks!

I would probably add font-family:monospace; to the style.

1 Like