'Render an arbitrary markdown document.
:param str text: (required), the text of the document to render
:param str mode: (optional), \'markdown\' or \'gfm\'
:param str context: (optional), only important when using mode \'gfm\',
this is the repository to use as the context for the rendering
:param bool raw: (optional), renders a document like a README.md, no
gfm, no context
:returns: str (or unicode on Python 2) -- HTML formatted text'

def markdown(self, text, mode=u'', context=u'', raw=False):

    data = None
    json = False
    headers = {}
    if raw:
        url = self._build_url(u'markdown', u'raw')
        data = text
        headers[u'content-type'] = u'text/plain'
    else:
        url = self._build_url(u'markdown')
        data = {}
        if text:
            data[u'text'] = text
        if (mode in (u'markdown', u'gfm')):
            data[u'mode'] = mode
        if context:
            data[u'context'] = context
        json = True
    html = u''
    if data:
        req = self._post(url, data=data, json=json, headers=headers)
        if req.ok:
            html = req.text
    return html
