How to reference a IPython notebook cell in markdown? - ipython

How do I reference a cell in a IPython notebook markdown?
I know how to make a reference to an external link. But is there a way to assign an ID to a cell and then refer to the cell in the markdown?

Yes, there's way to do just that in IPython.
First, define the destination in the cell you want to link with a html anchor tag and give it an Id. For example:
<a id='another_cell'></a>
Note - When you run the above cell in markdown, it will become invisible. You can add some text above the anchor to identify the cell.
Second, create the internal hyperlink to the destination created above using Markdown syntax in another cell and run it:
[Another Cell](#another_cell)
Now, clicking on link should take you to the destination.

If you want to link directly to a specific section of your notebook, it can be useful to use this code: [section title](#section-title). Note that, for the text in the parentheses, you should replace spaces and special characters with a hyphen.
As an example, consider this case in which we want to insert a link to the section 'Univariate + One step ahead':
To do so, we just need to add the code [Univariate + One step ahead](#Univariate-+-One-step-ahead):
This way we avoid the introduction of an anchor tag, since the section title already acts as one.

Related

Force GitHub pages to render numerical lists sequentially instead of restarting?

I noticed that when GitHub pages with mkdocs have text or images in between numbers it ignores the numbering in the source document and instead restarts numbering. See here for an example of this.
Is there a way to force mkdocs to render the numbers in the original document instead of inventing its own?
If you add them all as 1. space and text, then sub item as image with a tab, it should work. As an example:
1. Option 1
imgage or next text
1. Option 2
You can check this documentation built using mkdocs as an example.
As Zoran mentioned above that was part of it. Things I figured out:
Code must be double tabbed - you cannot use ```
Indented lists must also be double tabbed - I wasn't able to get a single tab to work
Images do not have to be tabbed - they can be in line with the above text
There should not be an empty line when an image follows a numbered list item BUT FOR CODE there must.
I still haven't completely figured out. mkdoc's behavior is not as predictable as regular markdown

Using vscode with Jupyter extension, how to find/replace text within a notebook cell [duplicate]

As the title says, how to find and replace text inside a single jupyter cell when using the jupyter extension in Visual Studio Code? I am familiar with ctr+h but that will replace all the occurrences in the entire jupyter notebook file. This is a really important feature for me, as I am using it a lot in jupyter on the browser.
2023-02-09 update
For the most updated VSCode, select something you would like to replace, and then F2.
Original answer
F3 do the trick. It first shows the "Find" widget for a single cell. Then click the triangle on the left, which will be expanded to a "Replace" widget.
You can select the first occurrence and then use Ctrl+D. It will select the next occurence in the cell. Repeat that until you go back to the first ocurrence and then type the new value. It will replace all the values your circled on.
In case you have changed that keyboard shortcut or if it is different you can find the correct one:
try select a cell and use Ctrl+g as I just found out accidentally.

jupyter - how to comment out cells?

Is it possible to comment out whole cells in jupyter?
I need it for this case:
I have a lot of cells, and I want to run all of them, except for a few of them. I like it that my code is organized in different cells, but I don't want to go to each cell and comment out its lines. I prefer to somehow choose the cells I want to comment out, then comment them out in one go (so I could later easily uncomment them)
Thanks
Mark the content of the cell and press Ctrl+ /. It will comment out all lines in that cell. Repeat the same steps to uncomment the lines of your cell.
I think the easiest thing will be to change the cell type to 'Markdown' with M when you don't want to run it and change back to 'Code' with Y when you do. In a short test I did, I did not lose my formatting when switching back and forth.
I don't think you can select multiple cells at once.
If you switch the cell to 'raw NBConvert' the code retains its formatting, while all text remains in a single font (important if you have any commented sections), so it remains readable. 'Markdown' will interpret the commented sections as headers and change the size and colour accordingly, making the cell rather messy.
On a side note I use this to interrupt the process if I want to stop it - it seems much more effective than 'Kernel --> Interrupt'.
You can switch the cell from 'Code to 'Raw NBConvert'

How to modify the tooltip for various eclipse commands e.g. Paste, Cut, Copy

I want to modify the existing tool tip text.I have following lines in plugin.xml
<command commandId="org.eclipse.ui.edit.paste"
id="org.eclipse.ui.edit.paste" tooltip="%pasteAction.TIP">
in plugin.properties
pasteAction.TIP=Paste
Existing tool tip appears like following
Paste(Ctrl+V)
I want to modify this existing tool tip to appears like following
Paste(Ctrl+V)
Paste a reference to the object
I am getting three problems to achieve this use case.
(Ctrl+V) added automatically at the end of tool tip text. which is not desired. It should appear where it is expected.
don't know how to Bold the particular string e.g. (Ctrl+V)
don't know how to make tool tip text multiline
we can use \n for multiline. it works but still looking for other two questions.
Thanks
For controls that you create you can use the org.eclipse.jface.window.ToolTip class to define custom tool tips.
For controls that Eclipse creates I don't know of any way to change the position of the key binding text or the font (bold).

How can i create a textarea that has read and write lines using gtk

Any one know how i can create a text area which displays lines of text which can not be edited but allows you to edit the bottom most line for text.
basically in a similar fashion to embedded consoles inside applications that allow you to run code direct on the application.
currently using a textview i can go and edit the code above and the output response are also editable.
It's possible using a GtkTextView, but not trivial. You have to create a tag that makes the text uneditable, and apply it from the beginning of the buffer to just before the end position. Then when you receive and process input, extend or re-apply the tag to cover that line of input and your program's response to it.
Here's an example of it being done:
creating the tag
applying the tag