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
cell magics do not work with empty lines after #2447 #3178
Comments
Hmm, that sounds like a consequence of #2447. I'll look into it. -f is force, i.e. don't prompt before overwriting the file. I agree that it should be documented. |
there was a leftover mention of `-f`, which doesn't actually exist. see ipython#3178
|
This seems to be a general problem with cell magics, the perl magic also doesn't work with newlines in the cell:
produces:
while a version without a newline works as expected:
produces:
|
Yep, it will affect all cell magics. If you do |
But I thought that algorithm for detecting cell magics was dead simple. If The cell begins with double percent the rest of the cel is handled as a cell magic, right? Sent from my iPhone On Apr 18, 2013, at 1:43 PM, Thomas Kluyver notifications@github.com wrote:
|
Yep, but for the line-based frontends, we decide when a cell magic is complete and ready to execute by looking for a blank line. That also lets you use cell magics in a .ipy script. The code path for 'is this block of input complete' needs to be slightly different from the code path for 'run this complete cell'. At present, my thinking is to have an attribute of input transformers that indicates whether they're used for completion testing, cell transformation, or both (the default, and what most will use). Then the rule will be that if your input transformer doesn't do both, it must be one of a pair that do both together. Once I've worked out the right API for this, I'll put together a pull request for it. |
See PR #3203 |
Separate InputSplitter for transforming whole cells This allows cell magics to include blank lines once again (closes #3178). InteractiveShell now has two input splitters: - `input_splitter` is used to determine when a block of input is complete, so you can use a cell magic in the terminal by leaving a blank line at the end. - `input_transformer_manager` is used to transform whole cells, so cell magics affect the whole of their cell. I removed the similar concept of 'input modes' for InputSplitter, because it was bound to get conflated, and it made the code rather hard to follow.
there was a leftover mention of `-f`, which doesn't actually exist. see ipython#3178
* input_splitter is used to detect when a cell is complete * input_transformer_manager transforms completed cells Closes ipythongh-3178
Separate InputSplitter for transforming whole cells This allows cell magics to include blank lines once again (closes ipython#3178). InteractiveShell now has two input splitters: - `input_splitter` is used to determine when a block of input is complete, so you can use a cell magic in the terminal by leaving a blank line at the end. - `input_transformer_manager` is used to transform whole cells, so cell magics affect the whole of their cell. I removed the similar concept of 'input modes' for InputSplitter, because it was bound to get conflated, and it made the code rather hard to follow.
a file cell magic looking like this:
will give an error with the current 1.0dev git head but it worked fine with 0.13.2
removing the empty line avoids the issue, but that is not really acceptable for readability
Also the docstring says for the notebook -f is implied but it does not say what -f does.
The text was updated successfully, but these errors were encountered: