Skip to content

Commit 424d275

Browse files
committed
fix some bugs, LaTeXTools should work inside Markdown cells
1 parent 89efae3 commit 424d275

4 files changed

Lines changed: 69 additions & 4 deletions

File tree

SublimeIPythonNotebook.tmLanguage

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
2+
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
55
<key>fileTypes</key>
@@ -46,6 +46,38 @@
4646
</dict>
4747
</array>
4848
</dict>
49+
<dict>
50+
<key>begin</key>
51+
<string>\#Markdown
52+
</string>
53+
<key>beginCaptures</key>
54+
<dict>
55+
<key>0</key>
56+
<dict>
57+
<key>name</key>
58+
<string>comment</string>
59+
</dict>
60+
</dict>
61+
<key>contentName</key>
62+
<string>ipynb.text.tex.latex text.tex.latex</string>
63+
<key>end</key>
64+
<string>\#\/Markdown</string>
65+
<key>endCaptures</key>
66+
<dict>
67+
<key>0</key>
68+
<dict>
69+
<key>name</key>
70+
<string>comment</string>
71+
</dict>
72+
</dict>
73+
<key>patterns</key>
74+
<array>
75+
<dict>
76+
<key>include</key>
77+
<string>text.tex.latex</string>
78+
</dict>
79+
</array>
80+
</dict>
4981
<dict>
5082
<key>begin</key>
5183
<string>\#Input\[(.*)\]\n</string>

SublimeIPythonNotebook.tmLanguage.JSON

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,25 @@
3030
]
3131
},
3232

33+
{
34+
35+
"contentName": "ipynb.text.tex.latex text.tex.latex",
36+
"begin": "\\#Markdown\n",
37+
"end": "\\#\\/Markdown",
38+
"beginCaptures": {
39+
"0": { "name": "comment"}
40+
},
41+
"endCaptures": {
42+
"0": { "name": "comment"}
43+
},
44+
"patterns": [
45+
{
46+
"include": "text.tex.latex"
47+
},
48+
]
49+
},
50+
51+
3352
{
3453
"contentName": "ipynb.source.input.python",
3554
"begin": "\\#Input\\[(.*)\\]\\n",

TODO.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,10 @@
66
- Support set_next_input
77
- Add an option of saving a backup copy of notebook json file (use git to have all copies?):
88
- For now it is possible to use inb_open_as_ipynb command
9-
- Support image preview in some external program
9+
- Support image preview in some external program
10+
11+
BUGS:
12+
13+
TODO for IPython 1.0
14+
15+
- support stdin input for %debug, raw_input and so on

ipy_view.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ def get_input_content(self):
9797
return self.view.substr(input_region)
9898
else:
9999
return ""
100+
101+
def check_R(self):
102+
pass
100103

101104

102105
class CodeCellView(BaseCellView):
@@ -260,7 +263,7 @@ def setup(self, edit):
260263
reg = sublime.Region(start, end)
261264
regs = view.get_regions("inb_input")
262265
regs.append(reg)
263-
view.add_regions("inb_input", regs, "text.tex.latex", "", input_draw_style)
266+
view.add_regions("inb_input", regs, "source.python", "", input_draw_style)
264267
self.view.set_read_only(False)
265268

266269
end = end + view.insert(edit, end, "#/" + self.get_cell_title())
@@ -356,7 +359,7 @@ def on_modified(self):
356359
for s in self.view.sel():
357360
for i, reg in enumerate(regset):
358361
reg = sublime.Region(reg.begin()+1, reg.end()-1)
359-
if reg.contains(s):
362+
if reg.contains(s) and (i < len(self.cells)):
360363
self.cells[i].check_R()
361364
break
362365

@@ -484,6 +487,11 @@ def set_status():
484487
sublime.set_timeout(set_status, 0)
485488

486489
def handle_completions(self, view, prefix, locations):
490+
cell_index = self.get_current_cell_index()
491+
if cell_index < 0:
492+
return None
493+
if not isinstance(self.cells[cell_index], CodeCellView):
494+
return None
487495
sel = view.sel()
488496
if len(sel) > 1:
489497
return []

0 commit comments

Comments
 (0)