ENH: Use python/markdown mode in input/markdown cells #11

Closed
spencerlyon2 opened this Issue Oct 4, 2013 · 19 comments

Projects

None yet

2 participants

@spencerlyon2

First, this is a great plugin. Good work.

I don't know if it is possible, but it would be awesome if we could figure out how to make sublime treat python cells as an actual python script so things like snippets and completions work. The same goes for markdown.

In reality, if we figure this out, I would like to have markdown cells treated as latex. I do a lot of latex math in python notebooks and having LaTeXTools snippets and completions at my disposal would be ideal. Perhaps, we could let there be an option in a user preferences file that says which syntax rule sublime should follow for each type of cell.

@maximsch2
Owner

I am not sure if we are going to achieve full compatibility with all features of TeX/Python modes without integrating them into SublimeIPythonNotebook, but I think at least LaTexTools completions should now work in git master version. Can you try it out? If it will work fine, I'll push it as an update to Package Control.

Having an option will be non-trivial btw, because it looks like you have to rebuild tmLanguage file to change syntax inside parts of your document.

@spencerlyon2

The completions associated with "scope": "text.tex.latex" work in a markdown cell!

However, I find the most useful completions are the ones associated with math mode (see link for what that scope is). Any chance we can get those to work inside a latex environment or math delimiters $?

@maximsch2
Owner

Some of those completions actually do work for me, but it looks like they are overridden by global tex completions when overlapping...

@spencerlyon2

Ok the ones I am looking for are, for example, the greek letters.

  • a [TAB] -> \alpha
  • b [TAB] -> \beta

ect...

@maximsch2
Owner

Yeah, those don't work. You should be able to confirm using Command-Alt-P that "string.other.math.tex" is present inside the math delimiters, so I am not sure what we can do here...

@spencerlyon2

When I do Command-Alt-p I only se source.ipynb in the status bar. Are you getting something different?

@maximsch2
Owner

Yes, I am seeing text.tex.latex and other stuff there. Do you have your cursor inside the math block?

@spencerlyon2

Yeah, I have tried it both just in between $ $ and in an environment like \begin{align}. Still only seeing source.ipynb

@maximsch2
Owner

What about just inside the markdown cell? Can you also try $$ $$? If you don't have "text.tex.latex" there, then I don't know how are you getting any completions. I've tested it in ST2, let me see what happens in ST3.

@spencerlyon2

At random places in the markdown cell I still only get source.ipynb. Also in $$ $$.

I am using ST3, sorry I forgot to mention that earlier.

I also don't know how I am getting completions. Very strange

@maximsch2
Owner

OK, are you sure you have the latest version from github (not from Package Control)? I've tested it in ST3 and it works fine (I get source.tex.latex scope inside markdown cells, still no completion for alpha though)

@spencerlyon2

I deleted the one from package control (Installed\ Packages/IPython\ Notebook.sublime-package) and cloned the latest master into Packages/SublimeIPythonNotebook.

@spencerlyon2

It is odd, however, that from the command palette I am seeing duplicates for all the SublimeIpythonNotebook's commands

@maximsch2
Owner

So completion was working there all along? You should clone github master into Packages/IPython Notebook

@spencerlyon2

Ok so I just manually deleted the package, but didn't tell package control to remove it, so Package control kept downloading it again. Give me a minute to test a clean wipe/pull

@spencerlyon2

Ok I got that straightened out. I now see that all LaTeX elements are being highlighted properly and that I have the correct scope when I do Command-Alt-p

Also when I am in between $ $ I can do a [TAB] -> \alpha!! Looks like you got it figured out

@spencerlyon2

Did the math completions just figure themselves out on their own?

I am assuming that all you needed to do was make a markdown cell LaTeX, and then LaTeXTools took over the math related scope issues. Is that correct?

@maximsch2
Owner

Looks like it

@maximsch2 maximsch2 closed this in cc56a21 Oct 4, 2013
@maximsch2
Owner

New version in Package Control (should appear there in ~1 hour) should allow snippet completions for Python, R and LaTeX inside Markdown cells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment