Add a function to find cells with the requested tags
See original GitHub issueThis is a simple, isolated issue.
We have a function to iterate over cells to find one with the given tag:
However, this function has to clean up all cells with the given cells:
We’re currently iterating the notebook one per tag but it’d be better to search for all tags on a single pass.
For example, if my input is:
tags = ['a', 'b', 'c']
After running the function, the output should return a dictionary with the tags and its corresponding index:
# 'a' is in the first cell, etc...
result = {'a': 0, 'b': 10, 'c': 20}
Note that cells may have more than one tag, but as long as it contains the one we are looking for, we don’t care about the rest.
If the cell is not in the notebook, it should not appear in the output. Following our previous example:
# input
tags = ['a', 'b', 'c']
Output:
# if we only get 'a', it means 'b' and 'c' are not in the notebook
result = {'a': 0}
I recently wrote something like this, except it looks for lines in a text file, as opposed to cells in a notebook, but the general logic remains the same.
Tasks:
- Write a function that supports multiple tags
- Have
_cleanup_rendered_nb
use that new function
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Sure! feel free to open a PR!
thanks for your interest!