Skip to content

Commit

Permalink
use urllib rather than requests
Browse files Browse the repository at this point in the history
  • Loading branch information
315234 committed Jun 30, 2016
1 parent 851dee4 commit fc0e08a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions InlineLatexHover.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sublime_plugin

import urllib.parse
import requests
import urllib.request
from base64 import b64encode

class InlineLatexHover(sublime_plugin.EventListener):
Expand All @@ -22,10 +22,11 @@ def on_hover(self, view, point, hover_zone):
bg, fg = 'ffffff', '222222'
params = urllib.parse.urlencode({'cht': "tx", 'chl': latex, 'chf': 'bg,s,'+bg, 'chco': fg})
imgurl = "http://chart.googleapis.com/chart?"+params
response = requests.get(imgurl)
imgdata = b64encode(response.content).decode()
html_str = '<img src="data:image/png;base64,%s" />' % imgdata
view.show_popup(html_str, sublime.HIDE_ON_MOUSE_MOVE, point)
with urllib.request.urlopen(imgurl) as response:
rawdata = response.read()
imgdata = b64encode(rawdata).decode()
html_str = '<img src="data:image/png;base64,%s" />' % imgdata
view.show_popup(html_str, sublime.HIDE_ON_MOUSE_MOVE, point)

@staticmethod
def extract_inline_latex_scope(view, point):
Expand Down

0 comments on commit fc0e08a

Please sign in to comment.