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

Spyder IDE cell support #9

Open
MarcusJones opened this issue Jul 3, 2018 · 0 comments
Open

Spyder IDE cell support #9

MarcusJones opened this issue Jul 3, 2018 · 0 comments

Comments

@MarcusJones
Copy link

Just hacked this together for Spyder - shall I make a PR? Is this project still active?
Inside def convert_toplevel_docstring(tokens):

        elif token.type == tokenize.COMMENT:
            text = token.string
            if text.startswith('#%%'):
                #print("Spyder cell")
                startline, startcol = token.start
                # Starting column MUST be 0
                if startcol == 0:
                    endline, endcol = token.end
                    lines = [line
                             for line in text.strip('"\' \n').split('\n')]
                    assert len(lines) == 1
                    text = '\n'.join(lines)
                    #text = text[3:]
                    text = text.replace("#%%", "") 
                    text = text.lstrip()
                    fmt = '# <markdowncell>\n{0}\n# <codecell>'.format(text)
                    res = TokenInfo(type=tokenize.COMMENT,
                                    start=(startline, startcol),
                                    end=(endline, endcol),
                                    string=fmt,
                                    line='#')
                    yield res
                    # To next token
                    continue  
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

1 participant