This repository has been archived by the owner. It is now read-only.

Is it possible to support github flavored markdown #27

Closed
335g opened this Issue Aug 12, 2012 · 82 comments

Comments

Projects
None yet
@335g

335g commented Aug 12, 2012

I've tried to modified MarkdownPreview.py:

before

markdown_html = markdown.markdown(contents)

after

data = json.dumps({"text":contents, "mode":"gfm"})
url = "https://api.github.com/markdown"
value = urllib2.urlopen(url, data)
html = value.read()
markdown_html = markdown.markdown(html)

I can see html.
But I cannot use normal markdown preview in this case.

I think that I must support css too.

Do you have any plan to support github flavored markdown?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Aug 12, 2012

Owner

Thats indeed a very good idea, i didn't know that GH provide markdown in their API.

I think the better would be to create a separate plugin because

  1. it will be slower
  2. not everyboy wants his code to be sent to GH

So if you're ok with this, i can create that new plugin in the next days

Owner

revolunet commented Aug 12, 2012

Thats indeed a very good idea, i didn't know that GH provide markdown in their API.

I think the better would be to create a separate plugin because

  1. it will be slower
  2. not everyboy wants his code to be sent to GH

So if you're ok with this, i can create that new plugin in the next days

@335g

This comment has been minimized.

Show comment
Hide comment
@335g

335g Aug 13, 2012

Thank you for reply.

  1. it will be slower
  2. not everyboy wants his code to be sent to GH

I think so certainly.
It's a good idea, but I thought that it can branch by the argument (ex, User Setting) .

So if you're ok with this, i can create that new plugin in the next days

Thank you !!
I'm waiting in the hope.

335g commented Aug 13, 2012

Thank you for reply.

  1. it will be slower
  2. not everyboy wants his code to be sent to GH

I think so certainly.
It's a good idea, but I thought that it can branch by the argument (ex, User Setting) .

So if you're ok with this, i can create that new plugin in the next days

Thank you !!
I'm waiting in the hope.

@isimmons

This comment has been minimized.

Show comment
Hide comment
@isimmons

isimmons Aug 13, 2012

Yes, thanks for the great plugin but while looking at a tutorial on md the first thing I looked at was github md and realized I can change these options in markdown pad(for windows) but would much rather do everything from ST2. If it's not too difficult, having a user setting to make the flavor optional would be awesome.

Yes, thanks for the great plugin but while looking at a tutorial on md the first thing I looked at was github md and realized I can change these options in markdown pad(for windows) but would much rather do everything from ST2. If it's not too difficult, having a user setting to make the flavor optional would be awesome.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Aug 13, 2012

Owner

what do you think ? separate plugin or user settings ?

Owner

revolunet commented Aug 13, 2012

what do you think ? separate plugin or user settings ?

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Aug 13, 2012

User settings would be the way to go.
This feature would be much appreciated!

User settings would be the way to go.
This feature would be much appreciated!

@335g

This comment has been minimized.

Show comment
Hide comment
@335g

335g Aug 14, 2012

I think that separate plugin is good idea.

335g commented Aug 14, 2012

I think that separate plugin is good idea.

@isimmons

This comment has been minimized.

Show comment
Hide comment
@isimmons

isimmons Aug 15, 2012

Yeah thinking about it, a separate plugin would be great so we can setup key bindings for each depending on which flavor we're using.

I was thinking user setting too but that would require editing the user setting every time we want to switch wouldn't it?

Thanks

Yeah thinking about it, a separate plugin would be great so we can setup key bindings for each depending on which flavor we're using.

I was thinking user setting too but that would require editing the user setting every time we want to switch wouldn't it?

Thanks

@parkeryoung

This comment has been minimized.

Show comment
Hide comment
@parkeryoung

parkeryoung Sep 6, 2012

Any progress on this?

Any progress on this?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 6, 2012

Owner

Yes... the conversion works but i have problems to find a correct CSS.

Anyone knows if we can get the github markdown CSS from somewhere ? +@mojombo ?

Owner

revolunet commented Sep 6, 2012

Yes... the conversion works but i have problems to find a correct CSS.

Anyone knows if we can get the github markdown CSS from somewhere ? +@mojombo ?

@mihaipaun

This comment has been minimized.

Show comment
Hide comment
@mihaipaun

mihaipaun Sep 7, 2012

You can also try and get in touch with @chenluois, who is the creator of Moo. Moo app has this setting where you can use GitHub flavoured markdown CSS: http://cl.ly/image/1x0a2p3r0G1U and perhaps he can point you in the right direction.

You can also try and get in touch with @chenluois, who is the creator of Moo. Moo app has this setting where you can use GitHub flavoured markdown CSS: http://cl.ly/image/1x0a2p3r0G1U and perhaps he can point you in the right direction.

@parkeryoung

This comment has been minimized.

Show comment
Hide comment
@parkeryoung

parkeryoung Sep 7, 2012

After a quick google search I found https://gist.github.com/2554919 I haven't looked at what the result of that css actually looks like though.

After a quick google search I found https://gist.github.com/2554919 I haven't looked at what the result of that css actually looks like though.

revolunet added a commit that referenced this issue Sep 8, 2012

Merge pull request #32 from danmactough/master
Partially fix issue #27: support Github Flavored Markdown
@parkeryoung

This comment has been minimized.

Show comment
Hide comment
@parkeryoung

parkeryoung Sep 11, 2012

@revolunet have you taken a look at the CSS I posted to see if it is appropriate?

@revolunet have you taken a look at the CSS I posted to see if it is appropriate?

@revolunet revolunet closed this in ff23e40 Sep 11, 2012

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 11, 2012

Owner

Ho Hi :)
Just pushed an update. you can now set "parser": "github" in the settings to use the github markdown API and github.css.
Please confirm everything is ok for you all !
Cheers

Owner

revolunet commented Sep 11, 2012

Ho Hi :)
Just pushed an update. you can now set "parser": "github" in the settings to use the github markdown API and github.css.
Please confirm everything is ok for you all !
Cheers

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

Seems there is still a problem.

When I try to preview:

cannot use github API to convert markdown. Please check your settings.

With the following settings:

{
    "browser": "default",
    "parser": "github",
    "css": "default"
}

Seems there is still a problem.

When I try to preview:

cannot use github API to convert markdown. Please check your settings.

With the following settings:

{
    "browser": "default",
    "parser": "github",
    "css": "default"
}
@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

thanks

can you please open the ST2 console and tell me if this works :

import json
Owner

revolunet commented Sep 12, 2012

thanks

can you please open the ST2 console and tell me if this works :

import json
@mihaipaun

This comment has been minimized.

Show comment
Hide comment
@mihaipaun

mihaipaun Sep 12, 2012

Seems to be working for me.

Seems to be working for me.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

@tijptjik would be nice if you could open your ST2 console and paste any traceback here

Owner

revolunet commented Sep 12, 2012

@tijptjik would be nice if you could open your ST2 console and paste any traceback here

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

ah yes! That's more useful.

error: cannot use github API to convert markdown. Please check your
settings.
Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./MarkdownPreview.py", line 117, in run
UnboundLocalError: local variable 'markdown_html' referenced before
assignment

The plugin updated with Package Control is the latest version with GFM support right?

ah yes! That's more useful.

error: cannot use github API to convert markdown. Please check your
settings.
Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./MarkdownPreview.py", line 117, in run
UnboundLocalError: local variable 'markdown_html' referenced before
assignment

The plugin updated with Package Control is the latest version with GFM support right?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

@tijptjik ok i initialized the variable but this doesnt help with the github failed conversion.

do you have any proxy ?

the github APi is accessible via https://api.github.com/markdown

Owner

revolunet commented Sep 12, 2012

@tijptjik ok i initialized the variable but this doesnt help with the github failed conversion.

do you have any proxy ?

the github APi is accessible via https://api.github.com/markdown

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

No proxy, and I can access GitHub API just fine from a REST console.

No proxy, and I can access GitHub API just fine from a REST console.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

hum... can you please comment the try/except clause from line 93 in MarkdownPreview.py to get the full traceback ?

Owner

revolunet commented Sep 12, 2012

hum... can you please comment the try/except clause from line 93 in MarkdownPreview.py to get the full traceback ?

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./MarkdownPreview.py", line 95, in run
  File ".\urllib2.py", line 126, in urlopen
  File ".\urllib2.py", line 391, in open
  File ".\urllib2.py", line 414, in _open
  File ".\urllib2.py", line 369, in _call_chain
  File ".\urllib2.py", line 1194, in unknown_open
urllib2.URLError: <urlopen error unknown url type: https>

Could it have to do with the version of Python I'm working with?

>>> sys.version
'2.6.6 (r266:84292, Jun 16 2011, 22:27:44) \n[GCC 4.4.5]'
Traceback (most recent call last):
  File "./sublime_plugin.py", line 356, in run_
  File "./MarkdownPreview.py", line 95, in run
  File ".\urllib2.py", line 126, in urlopen
  File ".\urllib2.py", line 391, in open
  File ".\urllib2.py", line 414, in _open
  File ".\urllib2.py", line 369, in _call_chain
  File ".\urllib2.py", line 1194, in unknown_open
urllib2.URLError: <urlopen error unknown url type: https>

Could it have to do with the version of Python I'm working with?

>>> sys.version
'2.6.6 (r266:84292, Jun 16 2011, 22:27:44) \n[GCC 4.4.5]'
@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

oops, look like SSL is not supported in Python installation.
im looking for solutions

Owner

revolunet commented Sep 12, 2012

oops, look like SSL is not supported in Python installation.
im looking for solutions

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

is there a package I could install with pip that would solve this problem?
Or, why does it work for some other peeps :)?

is there a package I could install with pip that would solve this problem?
Or, why does it work for some other peeps :)?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

@tijptjik can you tell your linux distro plz ?

Owner

revolunet commented Sep 12, 2012

@tijptjik can you tell your linux distro plz ?

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

Fedora 17

Linux qi 3.5.3-1.fc17.x86_64 #1 SMP Wed Aug 29 18:46:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Have kept global as clean as possible from python package, and use virtualenv to install any additional packages.

Fedora 17

Linux qi 3.5.3-1.fc17.x86_64 #1 SMP Wed Aug 29 18:46:34 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Have kept global as clean as possible from python package, and use virtualenv to install any additional packages.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

heres some pointers : http://www.xinotes.org/notes/note/628/

looks like you need to recompile python with SSL support :/

please keep us informed thanks

Owner

revolunet commented Sep 12, 2012

heres some pointers : http://www.xinotes.org/notes/note/628/

looks like you need to recompile python with SSL support :/

please keep us informed thanks

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

Thanks for your help @revolunet.

Any idea why it seems like SublimeText is using a 2.6.6 interpreter when my global python intepreter is version 2.7.3?

Thanks for your help @revolunet.

Any idea why it seems like SublimeText is using a 2.6.6 interpreter when my global python intepreter is version 2.7.3?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

I think sublime uses its own python version. i have to dig in

Owner

revolunet commented Sep 12, 2012

I think sublime uses its own python version. i have to dig in

@tijptjik

This comment has been minimized.

Show comment
Hide comment
@tijptjik

tijptjik Sep 12, 2012

Yes, I think so too :)

Seems like ST2 is packaged with a v2.6 intepreter. Wondering how come it's working on other systems. Is everyone else who has reported it working using OSX? Also wondering how I'd be able to replace the intepreter sublime was packaged with :L

Yes, I think so too :)

Seems like ST2 is packaged with a v2.6 intepreter. Wondering how come it's working on other systems. Is everyone else who has reported it working using OSX? Also wondering how I'd be able to replace the intepreter sublime was packaged with :L

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

works on OSX here

Owner

revolunet commented Sep 12, 2012

works on OSX here

@parkeryoung

This comment has been minimized.

Show comment
Hide comment
@parkeryoung

parkeryoung Sep 12, 2012

I have an Ubuntu setup at home and an OSX setup at work. At home it didn't work at first, but I think it was just because of the caching that sublime does because I fiddled with settings and then ultimately changed them back to what they were, and it works fine. And on OSX it worked fine right after I upgraded the package.

I have an Ubuntu setup at home and an OSX setup at work. At home it didn't work at first, but I think it was just because of the caching that sublime does because I fiddled with settings and then ultimately changed them back to what they were, and it works fine. And on OSX it worked fine right after I upgraded the package.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 12, 2012

Owner

thanks for reporting

Owner

revolunet commented Sep 12, 2012

thanks for reporting

@parkeryoung

This comment has been minimized.

Show comment
Hide comment
@parkeryoung

parkeryoung Sep 12, 2012

Thank you for making this change, it has made this package much more valuable to me.

Thank you for making this change, it has made this package much more valuable to me.

@ghost

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Sep 14, 2012

I have a similar issue. I get Cannot use github to convert markdown. SSL is not included in your Python installation..
I only get this (so far) if I use the % symbol in my markdown; removing the % stops the error.

ghost commented Sep 14, 2012

I have a similar issue. I get Cannot use github to convert markdown. SSL is not included in your Python installation..
I only get this (so far) if I use the % symbol in my markdown; removing the % stops the error.

@aleiphoenix

This comment has been minimized.

Show comment
Hide comment
@aleiphoenix

aleiphoenix Sep 17, 2012

+1 to Cannot use github to convert markdown. SSL is not included in your Python installation.

may be escape the erb code or render them first?

+1 to Cannot use github to convert markdown. SSL is not included in your Python installation.

may be escape the erb code or render them first?

@panglaoying

This comment has been minimized.

Show comment
Hide comment
@panglaoying

panglaoying Sep 18, 2012

+1 to Cannot use github to convert markdown. SSL is not included in your Python installation.

+1 to Cannot use github to convert markdown. SSL is not included in your Python installation.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Sep 18, 2012

Owner

Looks like the GitHub API has a slight problem, see example here : https://gist.github.com/3742011

I'll report this to github.

Owner

revolunet commented Sep 18, 2012

Looks like the GitHub API has a slight problem, see example here : https://gist.github.com/3742011

I'll report this to github.

@Hubro

This comment has been minimized.

Show comment
Hide comment

Hubro commented Sep 27, 2012

@revolunet: Thanks

@mindfulmonk

This comment has been minimized.

Show comment
Hide comment
@mindfulmonk

mindfulmonk Nov 19, 2012

So is there a solution for Linux users to make github parser working?

So is there a solution for Linux users to make github parser working?

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Nov 19, 2012

Owner

No solution on this right now :/ the bundled Python does not include SSL and github API is ssl-only. So you have to use the builtin markdown parser

Owner

revolunet commented Nov 19, 2012

No solution on this right now :/ the bundled Python does not include SSL and github API is ssl-only. So you have to use the builtin markdown parser

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Nov 28, 2012

Owner

FYI the percent sign issue has been fixed, was due to missing header... (lol)

Owner

revolunet commented Nov 28, 2012

FYI the percent sign issue has been fixed, was due to missing header... (lol)

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 18, 2012

Contributor

Still no news I suppose? No work-arounds found for ssl? If there's a practical solution to this please gist it :)

Contributor

aponxi commented Dec 18, 2012

Still no news I suppose? No work-arounds found for ssl? If there's a practical solution to this please gist it :)

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Dec 18, 2012

Owner

no known workaround for me sorry :/
ask the ST2 team here : http://sublimetext.userecho.com/topic/50801-bundle-python-ssl-module/

Owner

revolunet commented Dec 18, 2012

no known workaround for me sorry :/
ask the ST2 team here : http://sublimetext.userecho.com/topic/50801-bundle-python-ssl-module/

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 19, 2012

Contributor

voted and such on the link you have provided, thank you for the fast reply! And keep up the good work! I love your plug-in!

Contributor

aponxi commented Dec 19, 2012

voted and such on the link you have provided, thank you for the fast reply! And keep up the good work! I love your plug-in!

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Dec 19, 2012

Owner

@aponxi , thanks to @wbond , i bundled the SSL module right in the plugin. i have no linux with GUI currently so can you please tell us if it works now ?

You need to :

  • update the plugin
  • in the Markdown Preview settings, set linux_enable_ssl:true
  • restart ST2

Cheers and bigup to @wbond for the help :)

Owner

revolunet commented Dec 19, 2012

@aponxi , thanks to @wbond , i bundled the SSL module right in the plugin. i have no linux with GUI currently so can you please tell us if it works now ?

You need to :

  • update the plugin
  • in the Markdown Preview settings, set linux_enable_ssl:true
  • restart ST2

Cheers and bigup to @wbond for the help :)

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 19, 2012

Contributor

Oh this is indeed great news! Thank you @wbond and @revolunet !!

I have tried testing it, but had no luck. But I might be doing something wrong since I'm fairly new to Sublime Text 2.

What I have done is:

  • ctrl+shift+P uninstall markdown preview
  • ctrl+shift+P install markdown preview
  • go to preferences of the plugin and set linux_enable_ssl:true
  • ctrl+Q to quit sublime
  • start sublime, open a markdown file and ctrl+shift+P preview markdown in browser

I get the same error:

Imgur
Imgur
Imgur

Contributor

aponxi commented Dec 19, 2012

Oh this is indeed great news! Thank you @wbond and @revolunet !!

I have tried testing it, but had no luck. But I might be doing something wrong since I'm fairly new to Sublime Text 2.

What I have done is:

  • ctrl+shift+P uninstall markdown preview
  • ctrl+shift+P install markdown preview
  • go to preferences of the plugin and set linux_enable_ssl:true
  • ctrl+Q to quit sublime
  • start sublime, open a markdown file and ctrl+shift+P preview markdown in browser

I get the same error:

Imgur
Imgur
Imgur

@wbond

This comment has been minimized.

Show comment
Hide comment
@wbond

wbond Dec 19, 2012

Just because the SSL module is loaded, does not mean the httplib module will use it. Likely the httplib module is being loaded before your package, and at that point the SSL module is not yet loaded.

You will probably have to play around with reloading httplib or possibly even urllib and urllib2 after you load ssl. I have not done this because I only use it for FTPS.

Another alternative to that is to look at the Package Control source and extract the Curl and Wget downloaders. Most linux installs come with one of those by default.

wbond commented Dec 19, 2012

Just because the SSL module is loaded, does not mean the httplib module will use it. Likely the httplib module is being loaded before your package, and at that point the SSL module is not yet loaded.

You will probably have to play around with reloading httplib or possibly even urllib and urllib2 after you load ssl. I have not done this because I only use it for FTPS.

Another alternative to that is to look at the Package Control source and extract the Curl and Wget downloaders. Most linux installs come with one of those by default.

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Dec 19, 2012

Owner

just added a force reload on the urllib2 module to test.. @aponxi , tell me if its better please.

if not, i'll go the curl way, like in the gist plugin or the package control source.

Owner

revolunet commented Dec 19, 2012

just added a force reload on the urllib2 module to test.. @aponxi , tell me if its better please.

if not, i'll go the curl way, like in the gist plugin or the package control source.

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 19, 2012

Contributor

@revolunet Unfortunately it didn't work :( Still getting the same error after following the same steps: upgrade, set settings and restart ST2.

Contributor

aponxi commented Dec 19, 2012

@revolunet Unfortunately it didn't work :( Still getting the same error after following the same steps: upgrade, set settings and restart ST2.

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 21, 2012

Contributor

@revolunet Maybe the console output will help (although I'm not sure if its that important to load 0.9.8 since it successfully loads 1.0.0), I just noticed this error:

I added print to see which directory it looked for and couldn't find the _ssl module for 0.9.8 here on the third line:

for ssl_ver in ['0.9.8', '1.0.0', '10']:
        lib_path = os.path.join(arch_lib_path, 'libssl-' + ssl_ver)
        print "lib_path: " + lib_path
        try:
            m_info = imp.find_module('_ssl', [lib_path])
            m = imp.load_module('_ssl', *m_info)
            print 'Markdown Preview: successfully loaded _ssl module for libssl.so.%s' % ssl_ver
            break
        except (ImportError) as (e):
            print 'Markdown Preview: _ssl module import error - ' + str(e)
    if '_ssl' in sys.modules:
        plat_lib_path = os.path.join(sublime.packages_path(), 'Markdown Preview', 'lib',
            'linux')
        try:
            m_info = imp.find_module('ssl', [plat_lib_path])
            m = imp.load_module('ssl', *m_info)
        except (ImportError) as (e):
            print 'Markdown Preview: ssl module import error - ' + str(e)
    reload(urllib2)

The console output is:

Reloading plugin /home/nox/.config/sublime-text-2/Packages/Markdown Preview/MarkdownPreview.py
Markdown Preview: enabling custom linux ssl module
lib_path: /home/nox/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64/libssl-0.9.8
Markdown Preview: _ssl module import error - libssl.so.0.9.8: cannot open shared object file: No such file or directory
lib_path: /home/nox/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64/libssl-1.0.0
Markdown Preview: successfully loaded _ssl module for libssl.so.1.0.0
error: cannot use github API to convert markdown. SSL is not included in your Python installation

This is the folder structure of ssl libraries, it seemed legit to me however I might be missing something:

nox@green-flame:~/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64$ ls -lartR
.:
total 20
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-1.0.0
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-0.9.8
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-10
drwxrwxr-x 5 nox nox 4096 Dec 19 11:30 ..
drwxrwxr-x 5 nox nox 4096 Dec 19 11:30 .

./libssl-1.0.0:
total 144
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
-rw-rw-r-- 1 nox nox 128697 Dec 19 17:57 _ssl.so

./libssl-0.9.8:
total 124
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
-rw-rw-r-- 1 nox nox 110450 Dec 19 17:57 _ssl.so

./libssl-10:
total 148
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
-rw-rw-r-- 1 nox nox 132945 Dec 19 17:57 _ssl.so
Contributor

aponxi commented Dec 21, 2012

@revolunet Maybe the console output will help (although I'm not sure if its that important to load 0.9.8 since it successfully loads 1.0.0), I just noticed this error:

I added print to see which directory it looked for and couldn't find the _ssl module for 0.9.8 here on the third line:

for ssl_ver in ['0.9.8', '1.0.0', '10']:
        lib_path = os.path.join(arch_lib_path, 'libssl-' + ssl_ver)
        print "lib_path: " + lib_path
        try:
            m_info = imp.find_module('_ssl', [lib_path])
            m = imp.load_module('_ssl', *m_info)
            print 'Markdown Preview: successfully loaded _ssl module for libssl.so.%s' % ssl_ver
            break
        except (ImportError) as (e):
            print 'Markdown Preview: _ssl module import error - ' + str(e)
    if '_ssl' in sys.modules:
        plat_lib_path = os.path.join(sublime.packages_path(), 'Markdown Preview', 'lib',
            'linux')
        try:
            m_info = imp.find_module('ssl', [plat_lib_path])
            m = imp.load_module('ssl', *m_info)
        except (ImportError) as (e):
            print 'Markdown Preview: ssl module import error - ' + str(e)
    reload(urllib2)

The console output is:

Reloading plugin /home/nox/.config/sublime-text-2/Packages/Markdown Preview/MarkdownPreview.py
Markdown Preview: enabling custom linux ssl module
lib_path: /home/nox/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64/libssl-0.9.8
Markdown Preview: _ssl module import error - libssl.so.0.9.8: cannot open shared object file: No such file or directory
lib_path: /home/nox/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64/libssl-1.0.0
Markdown Preview: successfully loaded _ssl module for libssl.so.1.0.0
error: cannot use github API to convert markdown. SSL is not included in your Python installation

This is the folder structure of ssl libraries, it seemed legit to me however I might be missing something:

nox@green-flame:~/.config/sublime-text-2/Packages/Markdown Preview/lib/linux-x64$ ls -lartR
.:
total 20
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-1.0.0
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-0.9.8
drwxrwxr-x 2 nox nox 4096 Dec 19 11:30 libssl-10
drwxrwxr-x 5 nox nox 4096 Dec 19 11:30 ..
drwxrwxr-x 5 nox nox 4096 Dec 19 11:30 .

./libssl-1.0.0:
total 144
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
-rw-rw-r-- 1 nox nox 128697 Dec 19 17:57 _ssl.so

./libssl-0.9.8:
total 124
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
-rw-rw-r-- 1 nox nox 110450 Dec 19 17:57 _ssl.so

./libssl-10:
total 148
drwxrwxr-x 5 nox nox   4096 Dec 19 11:30 ..
drwxrwxr-x 2 nox nox   4096 Dec 19 11:30 .
-rw-rw-r-- 1 nox nox 132945 Dec 19 17:57 _ssl.so
@dusteye

This comment has been minimized.

Show comment
Hide comment
@dusteye

dusteye Dec 31, 2012

sublime use a python26.zip in itself.
Use pythonbrew can easily solve this problem:

curl -kL http://xrl.us/pythonbrewinstall | bash

pythonbrew is now installed in $HOME/.pythonbrew
add this line at end of .bashrc

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc

then use pythonbrew to install python 2.6

pythonbrew install --configure="--enable-unicode=ucs4 --with-zlib --with-ssl --with-threads --enable-share" 2.6

Note that the configure is mine, here just with ' --with-ssl' does matter
At last, make a link of the pythonbrew 2.6 lib to the sublime python2.6 lib

ln -s $HOME/.pythonbrew/pythons/Python-2.6/lib/python2.6 /Your_Sublime_Install_Path/lib/python2.6

Now sublime text will use python 2.6 lib under pythonbrew with ssl enabled.

dusteye commented Dec 31, 2012

sublime use a python26.zip in itself.
Use pythonbrew can easily solve this problem:

curl -kL http://xrl.us/pythonbrewinstall | bash

pythonbrew is now installed in $HOME/.pythonbrew
add this line at end of .bashrc

[[ -s $HOME/.pythonbrew/etc/bashrc ]] && source $HOME/.pythonbrew/etc/bashrc

then use pythonbrew to install python 2.6

pythonbrew install --configure="--enable-unicode=ucs4 --with-zlib --with-ssl --with-threads --enable-share" 2.6

Note that the configure is mine, here just with ' --with-ssl' does matter
At last, make a link of the pythonbrew 2.6 lib to the sublime python2.6 lib

ln -s $HOME/.pythonbrew/pythons/Python-2.6/lib/python2.6 /Your_Sublime_Install_Path/lib/python2.6

Now sublime text will use python 2.6 lib under pythonbrew with ssl enabled.

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 31, 2012

Contributor

It works!! Thank you @dusteye

Imgur

Contributor

aponxi commented Dec 31, 2012

It works!! Thank you @dusteye

Imgur

@dusteye

This comment has been minimized.

Show comment
Hide comment
@dusteye

dusteye Dec 31, 2012

@aponxi glad it did help. In fact there are several sublime plugins can't work on ubuntu due to lack of python lib, pythonbrew is a relatively elegant choice

dusteye commented Dec 31, 2012

@aponxi glad it did help. In fact there are several sublime plugins can't work on ubuntu due to lack of python lib, pythonbrew is a relatively elegant choice

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 31, 2012

Contributor

@dusteye I have one question, how does sublime know which python to use? I mean why does it choose the symlink we just brewed over the usual python26.zip ? What if I had anotther python lib symlink under sublime/lib, would it try to load both libs?

Contributor

aponxi commented Dec 31, 2012

@dusteye I have one question, how does sublime know which python to use? I mean why does it choose the symlink we just brewed over the usual python26.zip ? What if I had anotther python lib symlink under sublime/lib, would it try to load both libs?

@dusteye

This comment has been minimized.

Show comment
Hide comment
@dusteye

dusteye Dec 31, 2012

@aponxi Actually, the official document does not explain how it does deal with python26.zip and how to search python lib, but in sublime startup information(you cat get it in the console after sublime start) you can see that:

Py_GetProgramName(): sublime_text
Py_GetExecPrefix(): .
Py_GetProgramFullPath(): 
Py_GetPath(): ./lib/python26.zip:./lib/python2.6/:./lib/python2.6/plat-linux2:./lib/python2.6/lib-tk:./lib/python2.6/lib-old:./lib/python2.6/lib-dynload
Py_GetPythonHome(): .

I had made several test, no matter /lib/python2.6 exists or not, and no matter other version of python lib such as python2.7 exists, this startup information makes no difference.
It seems sublime hard coded './lib/python26.zip:./lib/python2.6/:./lib/python2.6/plat-linux2:./lib/python2.6/lib-tk:./lib/python2.6/lib-old:./lib/python2.6/lib-dynload' to the PYTHONPATH.

dusteye commented Dec 31, 2012

@aponxi Actually, the official document does not explain how it does deal with python26.zip and how to search python lib, but in sublime startup information(you cat get it in the console after sublime start) you can see that:

Py_GetProgramName(): sublime_text
Py_GetExecPrefix(): .
Py_GetProgramFullPath(): 
Py_GetPath(): ./lib/python26.zip:./lib/python2.6/:./lib/python2.6/plat-linux2:./lib/python2.6/lib-tk:./lib/python2.6/lib-old:./lib/python2.6/lib-dynload
Py_GetPythonHome(): .

I had made several test, no matter /lib/python2.6 exists or not, and no matter other version of python lib such as python2.7 exists, this startup information makes no difference.
It seems sublime hard coded './lib/python26.zip:./lib/python2.6/:./lib/python2.6/plat-linux2:./lib/python2.6/lib-tk:./lib/python2.6/lib-old:./lib/python2.6/lib-dynload' to the PYTHONPATH.

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Dec 31, 2012

Contributor

ah gotcha, thanks for the explanation @dusteye 👍

Contributor

aponxi commented Dec 31, 2012

ah gotcha, thanks for the explanation @dusteye 👍

@revolunet

This comment has been minimized.

Show comment
Hide comment
@revolunet

revolunet Dec 31, 2012

Owner

thanks @dusteye, you rock 👍 I'll add your protip to the README

Owner

revolunet commented Dec 31, 2012

thanks @dusteye, you rock 👍 I'll add your protip to the README

@marcantonio

This comment has been minimized.

Show comment
Hide comment
@marcantonio

marcantonio Jan 14, 2013

I just tried this on Ubuntu 12.10 and the building Python failed. It appears that others have had the same issue:

https://github.com/quarnster/SublimeClang/issues/35

The solution (towards the end off the page) is to run the same command that @dusteye posted, but with 2.6.7 rather than 2.6.

Just thought I'd mention it for everyone. Thanks guys!

I just tried this on Ubuntu 12.10 and the building Python failed. It appears that others have had the same issue:

https://github.com/quarnster/SublimeClang/issues/35

The solution (towards the end off the page) is to run the same command that @dusteye posted, but with 2.6.7 rather than 2.6.

Just thought I'd mention it for everyone. Thanks guys!

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Jan 14, 2013

Contributor

@marcantonio Interesting indeed... So you get an error in sublime text? or when brewing python 2.6 ? Could you please specify the error you get for referencing in the future please? Thanks :)

Contributor

aponxi commented Jan 14, 2013

@marcantonio Interesting indeed... So you get an error in sublime text? or when brewing python 2.6 ? Could you please specify the error you get for referencing in the future please? Thanks :)

@marcantonio

This comment has been minimized.

Show comment
Hide comment
@marcantonio

marcantonio Jan 14, 2013

The error occurs when building python. However, this led to another problem. Apparently, newer versions of Ubuntu don't include support for SSLv2 because of security issues. So when building Python the _ssl module doesn't compile. .. However, pythonbrew includes a patch to address this, but only applies the patch on versions of python <= 2.6.5. This is hardcoded into pythonbrew. 😡

tl;dr:

Run:

pythonbrew install --configure="--enable-unicode=ucs4 --with-zlib --with-ssl --with-threads --enable-share" 2.6.5

then:

ln -s $HOME/.pythonbrew/pythons/Python-2.6.5/lib/python2.6 /Your_Sublime_Install_Path/lib/python2.6

and everything comes up roses.

The error occurs when building python. However, this led to another problem. Apparently, newer versions of Ubuntu don't include support for SSLv2 because of security issues. So when building Python the _ssl module doesn't compile. .. However, pythonbrew includes a patch to address this, but only applies the patch on versions of python <= 2.6.5. This is hardcoded into pythonbrew. 😡

tl;dr:

Run:

pythonbrew install --configure="--enable-unicode=ucs4 --with-zlib --with-ssl --with-threads --enable-share" 2.6.5

then:

ln -s $HOME/.pythonbrew/pythons/Python-2.6.5/lib/python2.6 /Your_Sublime_Install_Path/lib/python2.6

and everything comes up roses.

@aponxi

This comment has been minimized.

Show comment
Hide comment
@aponxi

aponxi Jan 14, 2013

Contributor

@marcantonio ah I see... I downgraded from 12.10 to 12.04 for things like that... Plus I was getting app crashes too frequently...

Contributor

aponxi commented Jan 14, 2013

@marcantonio ah I see... I downgraded from 12.10 to 12.04 for things like that... Plus I was getting app crashes too frequently...

@OlivierBlanvillain OlivierBlanvillain referenced this issue in dotcypress/GitHubMarkdownPreview Jun 13, 2013

Closed

[RESEARCH] How does GitHubMarkdownPreview work? #2

@colthreepv

This comment has been minimized.

Show comment
Hide comment
@colthreepv

colthreepv Jul 22, 2013

My own solution linux-agnostic, it's based off nginx

First of all i created a nginx site, the syntax shown below it's from Ubuntu 12.04

$ sudo gedit /etc/nginx/sites-available/github

Content of site

server {
        listen 80;
        server_name github.localhost;

        location / {
                proxy_set_header Host api.github.com;
                proxy_pass https://api.github.com/;
        }

        access_log      /var/log/nginx/github_access.log combined;
        error_log       /var/log/nginx/github_error.log error;
}

add this in /etc/hosts

127.0.0.1    github.localhost

remember to reboot nginx sudo service nginx restart

Install Markdown Preview for Sublime Text 3:

$ cd .config/sublime-text-3/Packages/
$ git clone https://github.com/revolunet/sublimetext-markdown-preview.git 'Markdown Preview'
$ cd 'Markdown Preview'
$ git checkout ST3

Edit MarkdownPreview.py

--- a/MarkdownPreview.py
+++ b/MarkdownPreview.py
@@ -178,7 +178,7 @@ class MarkdownPreviewCommand(sublime_plugin.TextCommand):
                 if github_oauth_token:
                     headers['Authorization'] = "token %s" % github_oauth_token
                 data = json.dumps(data).encode('utf-8')
-                url = "https://api.github.com/markdown"
+                url = "http://github.localhost/markdown"
                 sublime.status_message(url)
                 request = urllib.request.Request(url, data=data, headers=headers)
                 markdown_html = urllib.request.urlopen(request).read().decode('utf-8')

And..

HAVE FUN!

My own solution linux-agnostic, it's based off nginx

First of all i created a nginx site, the syntax shown below it's from Ubuntu 12.04

$ sudo gedit /etc/nginx/sites-available/github

Content of site

server {
        listen 80;
        server_name github.localhost;

        location / {
                proxy_set_header Host api.github.com;
                proxy_pass https://api.github.com/;
        }

        access_log      /var/log/nginx/github_access.log combined;
        error_log       /var/log/nginx/github_error.log error;
}

add this in /etc/hosts

127.0.0.1    github.localhost

remember to reboot nginx sudo service nginx restart

Install Markdown Preview for Sublime Text 3:

$ cd .config/sublime-text-3/Packages/
$ git clone https://github.com/revolunet/sublimetext-markdown-preview.git 'Markdown Preview'
$ cd 'Markdown Preview'
$ git checkout ST3

Edit MarkdownPreview.py

--- a/MarkdownPreview.py
+++ b/MarkdownPreview.py
@@ -178,7 +178,7 @@ class MarkdownPreviewCommand(sublime_plugin.TextCommand):
                 if github_oauth_token:
                     headers['Authorization'] = "token %s" % github_oauth_token
                 data = json.dumps(data).encode('utf-8')
-                url = "https://api.github.com/markdown"
+                url = "http://github.localhost/markdown"
                 sublime.status_message(url)
                 request = urllib.request.Request(url, data=data, headers=headers)
                 markdown_html = urllib.request.urlopen(request).read().decode('utf-8')

And..

HAVE FUN!

@geekuillaume

This comment has been minimized.

Show comment
Hide comment
@geekuillaume

geekuillaume Aug 7, 2013

@MrGamer Don't forget to create a symbolic link in /etc/nginx/sites-enabled/ of your file /etc/nginx/sites-available/github to make it work

@MrGamer Don't forget to create a symbolic link in /etc/nginx/sites-enabled/ of your file /etc/nginx/sites-available/github to make it work

@zhouqianghfut

This comment has been minimized.

Show comment
Hide comment
@zhouqianghfut

zhouqianghfut Aug 12, 2013

@MrGamer Thx a lot. I am a ST3 user too.

@MrGamer Thx a lot. I am a ST3 user too.

@pablox-cl

This comment has been minimized.

Show comment
Hide comment
@pablox-cl

pablox-cl Sep 2, 2013

I tried the nginx solution, and works partially.. urls are auto-linked for example, but the auto-linked references like

revolunet/sublimetext-markdown-preview#27

revolunet/sublimetext-markdown-preview#27

Doesn't work... it has to do with SSL?

I tried the nginx solution, and works partially.. urls are auto-linked for example, but the auto-linked references like

revolunet/sublimetext-markdown-preview#27

revolunet/sublimetext-markdown-preview#27

Doesn't work... it has to do with SSL?

@silvadev

This comment has been minimized.

Show comment
Hide comment
@silvadev

silvadev Oct 7, 2013

@MrGamer The best solution. Leave the nginx to resolve HTTPS connections.

silvadev commented Oct 7, 2013

@MrGamer The best solution. Leave the nginx to resolve HTTPS connections.

@noquierouser

This comment has been minimized.

Show comment
Hide comment
@noquierouser

noquierouser Oct 10, 2013

I did what @dusteye commented, but still didn't work.

But looking at my terminal I found out this:

SFTP: enabling custom linux ssl module
SFTP: successfully loaded _ssl module for libssl.so.1.0.0

So maybe @wbond could give you a hand about it.

I did what @dusteye commented, but still didn't work.

But looking at my terminal I found out this:

SFTP: enabling custom linux ssl module
SFTP: successfully loaded _ssl module for libssl.so.1.0.0

So maybe @wbond could give you a hand about it.

@mvalim

This comment has been minimized.

Show comment
Hide comment
@mvalim

mvalim Oct 16, 2013

About the @MrGamer solution, if you already have Apache installed you can configure a reverse proxy instead of instaling nginx

<VirtualHost *:80>
ServerName github.localhost
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ProxyPass       /       https://api.github.com/
ProxyPassReverse    /       https://api.github.com/
Redirect Permanent  /       https://api.github.com/
CacheDisable *
<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/xml application/xhtml+xml "application/x-javascript \n\n" "text/html \n\n"
    DeflateCompressionLevel   9
</IfModule>
</VirtualHost>

mvalim commented Oct 16, 2013

About the @MrGamer solution, if you already have Apache installed you can configure a reverse proxy instead of instaling nginx

<VirtualHost *:80>
ServerName github.localhost
SSLProxyEngine On
RequestHeader set Front-End-Https "On"
ProxyPass       /       https://api.github.com/
ProxyPassReverse    /       https://api.github.com/
Redirect Permanent  /       https://api.github.com/
CacheDisable *
<IfModule mod_deflate.c> 
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript application/xml application/xhtml+xml "application/x-javascript \n\n" "text/html \n\n"
    DeflateCompressionLevel   9
</IfModule>
</VirtualHost>

tombh added a commit to tombh/sublimetext-markdown-preview that referenced this issue Oct 29, 2013

@tombh

This comment has been minimized.

Show comment
Hide comment
@tombh

tombh Oct 29, 2013

Contributor

I wrote this little bit of code to wrap curl. This way you don't have to mess about with a custom python install or proxying through your local web server. It's submitted as a Pull Request.

Contributor

tombh commented Oct 29, 2013

I wrote this little bit of code to wrap curl. This way you don't have to mess about with a custom python install or proxying through your local web server. It's submitted as a Pull Request.

@dotcypress dotcypress referenced this issue in dotcypress/GitHubMarkdownPreview Feb 19, 2014

Closed

Preview doesn't work? #6

@SnoringFrog SnoringFrog referenced this issue in SnoringFrog/GitlabIntegrate Oct 15, 2014

Open

Having trouble with HTTPS #5

@jeremiahmarks jeremiahmarks referenced this issue in condemil/Gist Mar 11, 2015

Closed

Gist: Error while contacting GitHub #153

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