Skip to content


Is it possible to support github flavored markdown #27

335g opened this Issue · 82 comments

I've tried to modified


markdown_html = markdown.markdown(contents)


data = json.dumps({"text":contents, "mode":"gfm"})
url = ""
value = urllib2.urlopen(url, data)
html =
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?


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


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.


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.


what do you think ? separate plugin or user settings ?


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


I think that separate plugin is good idea.


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?



Any progress on this?


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 ?


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: and perhaps he can point you in the right direction.


After a quick google search I found I haven't looked at what the result of that css actually looks like though.


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

@revolunet revolunet closed this in ff23e40

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 !


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"


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

import json

Seems to be working for me.


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


@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


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

Traceback (most recent call last):
  File "./", line 356, in run_
  File "./", line 95, in run
  File ".\", line 126, in urlopen
  File ".\", line 391, in open
  File ".\", line 414, in _open
  File ".\", line 369, in _call_chain
  File ".\", 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]'

oops, look like SSL is not supported in Python installation.

im looking for solutions


@tijptjik can you tell your linux distro plz ?


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.


heres some pointers :

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

please keep us informed thanks


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?


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


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


works on OSX here


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.


thanks for reporting


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


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.


+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.


Looks like the GitHub API has a slight problem, see example here :

I'll report this to github.


Also i removed percent signs temporary and added a better error message


+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 under Ubuntu


To all with "SSL problems" can you confirm you have an error when doing this in a python shell :

import _ssl

you should get an ImportError


you're right. can you find it somewhere in the app directory ?


Mmm so yes looks like the builtin python for Linux isnt built with SSL.

And the github API only accepts SSL so we're kinda stuck for this, sorry.

(Except setting up a proxy)


Can this be fixed? I can no longer use the Markdown preview plugin, which sucks.


@Codemonkey1991 : you can, just change "github" to "default" in your settings


github parser should not be the default, so i made the builtin the default in the settings.
please edit your settings guy


@revolunet: Thanks


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


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


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


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


no known workaround for me sorry :/
ask the ST2 team here :


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!


@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 :)


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:



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.


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.


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


@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
            m_info = imp.find_module('_ssl', [lib_path])
            m = imp.load_module('_ssl', *m_info)
            print 'Markdown Preview: successfully loaded _ssl module for' % ssl_ver
        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',
            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)

The console output is:

Reloading plugin /home/nox/.config/sublime-text-2/Packages/Markdown Preview/
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 - 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
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 .

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

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

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

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

curl -kL | 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.


It works!! Thank you @dusteye



@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 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 ? What if I had anotther python lib symlink under sublime/lib, would it try to load both libs?


@aponxi Actually, the official document does not explain how it does deal with 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_GetPath(): ./lib/
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/' to the PYTHONPATH.


ah gotcha, thanks for the explanation @dusteye :thumbsup:


thanks @dusteye, you rock :+1: I'll add your protip to the README


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

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!


@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 :)


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. :rage:



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


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

and everything comes up roses.


@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

The way GitHubMarkdownPreview supposed to work #2


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;

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

add this in /etc/hosts    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 'Markdown Preview'
$ cd 'Markdown Preview'
$ git checkout ST3


--- a/
+++ b/
@@ -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 = ""
+                url = "http://github.localhost/markdown"
                 request = urllib.request.Request(url, data=data, headers=headers)
                 markdown_html = urllib.request.urlopen(request).read().decode('utf-8')




@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 Thx a lot. I am a ST3 user too.


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



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


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


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

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


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       /
ProxyPassReverse    /
Redirect Permanent  /
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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.