Skip to content

Code blocks don't work right in ipython_directive #560

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

Closed
wesm opened this issue Dec 30, 2011 · 2 comments
Closed

Code blocks don't work right in ipython_directive #560

wesm opened this issue Dec 30, 2011 · 2 comments
Labels
Bug Build Library building on various platforms Docs
Milestone

Comments

@wesm
Copy link
Member

wesm commented Dec 30, 2011

No description provided.

@changhiskhan
Copy link
Contributor

I think this is working now (unless there was a more complex case you were thinking of?).

If I do:

.. ipython::

In [5]: long_series = Series(randn(1000))

In [6]: long_series.head()
Out[6]:
0   -0.663260
1   -2.169555
2    0.088584
3    2.220296
4   -0.149226

In [7]: long_series.tail(3)
Out[7]:
997   -1.818651
998   -1.341884
999   -0.033343

in basics.rst, the html output looks right (the output is replaced with newly sampled random numbers)

@wesm
Copy link
Member Author

wesm commented May 18, 2012

No. I mean stuff like:

.. ipython:: python

   for i in range(5):
       print 'foo'
       print 'bar'

The block parser is not "greedy" enough, it uses ast.parse to determine if lines read are valid Python code which they are after the first print statement. Can probably come up with a reasonable enough algorithm that looks at the indentation level to determine whether the block is done or not

@wesm wesm closed this as completed in 0bc7fec May 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Build Library building on various platforms Docs
Projects
None yet
Development

No branches or pull requests

2 participants