Skip to content
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

Incorrect parsing of raw multiline strings #2658

Closed
ayr0 opened this issue Dec 6, 2012 · 3 comments
Closed

Incorrect parsing of raw multiline strings #2658

ayr0 opened this issue Dec 6, 2012 · 3 comments
Milestone

Comments

@ayr0
Copy link

ayr0 commented Dec 6, 2012

IPython incorrectly parses the following input

test = r'''%@article {Cat61,
%    AUTHOR = {Cattabriga, Lamberto},
'''

I am parsing LaTeX, and IPython grabs each line starting with '%' as an ipython_magic function instead of correctly recognizing that '%' appears in a raw string.

"%    AUTHOR = {Cattabriga, Lamberto},\nget_ipython().magic(u'TITLE = {Su un problema al contorno relativo al sistema di equazioni di')\n"

The bad parsing is triggered by the comma and newline at the end of the first line.

test = r'''%test,
%test2
'''
"%test,\nget_ipython().magic(u'test2')\n"

test = r'''%test
%test2
'''
'%test\n%test2\n'
@ivanov
Copy link
Member

ivanov commented Dec 6, 2012

@ayr0 thanks for the report, but can you please provide more detail about what version of IPython you are running (ipython --version), and what client you are using (good ole terminal ipython, ipython qtconsole, console, web notebook?)

I am unable to reproduce the error you see on any of the recent version (git master, 0.13, 0.12, or 0.11)

@takluyver recently did some work on how these magics are processed, so he might have an idea.

@jasongrout
Copy link
Member

Hi Ryan :)

I can confirm that in IPython notebook, latest master (commit 6c36cd9), I have the following input/output in the notebook:

test = r'''%@article {Cat61,
%    AUTHOR = {Cattabriga, Lamberto},
'''

Then test is "%@article {Cat61,\nget_ipython().magic(u'AUTHOR = {Cattabriga, Lamberto},')\n" (note the magic call...)

If input is:

test = r'''%test,
%test2
'''

then test is "%test,\nget_ipython().magic(u'test2')\n"

I think this issue is probably related to gh-2628, and is probably a result of the code at https://github.com/ipython/ipython/blob/master/IPython/core/inputsplitter.py#L908 (just like gh-2628 is triggered by an omission at that line, as you can see from gh-2428).

@takluyver
Copy link
Member

This is essentially the same issue as #2612, so I'm going to close this, and we'll track it there. I have some ideas about how to fix it, but I want to get PR #2447 sorted out first.

@minrk minrk added this to the no action milestone Mar 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants