mirror of
https://github.com/status-im/PyGithub.git
synced 2026-09-01 11:21:16 +00:00
Implement markdown rendering (Issue #56)
This commit is contained in:
@@ -103,3 +103,20 @@ class Github( object ):
|
||||
None
|
||||
)
|
||||
return NamedUser.NamedUser( self.__requester, Legacy.convertUser( data[ "user" ] ), completed = False )
|
||||
|
||||
def render_markdown( self, text, context = GithubObject.NotSet ):
|
||||
assert isinstance( text, ( str, unicode ) ), text
|
||||
assert context is GithubObject.NotSet or isinstance( context, Repository.Repository ), context
|
||||
post_parameters = {
|
||||
"text": text
|
||||
}
|
||||
if context is not GithubObject.NotSet:
|
||||
post_parameters[ "mode" ] = "gfm"
|
||||
post_parameters[ "context" ] = context._identity
|
||||
status, headers, data = self.__requester.requestRaw(
|
||||
"POST",
|
||||
"https://api.github.com/markdown",
|
||||
None,
|
||||
post_parameters
|
||||
)
|
||||
return data
|
||||
|
||||
+2
-1
@@ -36,6 +36,7 @@ class Requester:
|
||||
|
||||
def requestAndCheck( self, verb, url, parameters, input ):
|
||||
status, headers, output = self.requestRaw( verb, url, parameters, input )
|
||||
output = self.__structuredFromJson( output )
|
||||
if status >= 400:
|
||||
raise GithubException.GithubException( status, output )
|
||||
return headers, output
|
||||
@@ -60,7 +61,7 @@ class Requester:
|
||||
|
||||
status = response.status
|
||||
headers = dict( response.getheaders() )
|
||||
output = self.__structuredFromJson( response.read() )
|
||||
output = response.read()
|
||||
|
||||
cnx.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user