Skip to content

Commit 58d6ccd

Browse files
committed
Added Markdown API
1 parent cfb8dcd commit 58d6ccd

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

lib/Github/Api/Markdown.php

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
namespace Github\Api;
4+
5+
/**
6+
* Markdown Rendering API
7+
*
8+
* @link http://developer.github.com/v3/markdown/
9+
* @author Joseph Bielawski <stloyd@gmail.com>
10+
*/
11+
class Markdown extends Api
12+
{
13+
/**
14+
* @param string $text
15+
* @param string $mode
16+
*
17+
* @return string
18+
*/
19+
public function render($text, $mode = 'markdown')
20+
{
21+
if (!in_array($mode, array())) {
22+
$mode = 'markdown';
23+
}
24+
25+
return $this->post('markdown', array(
26+
'text' => $text,
27+
'mode' => $mode
28+
));
29+
}
30+
31+
/**
32+
* @param string $file
33+
*
34+
* @return string
35+
*/
36+
public function renderRaw($file)
37+
{
38+
return $this->post('markdown/raw', array(
39+
'file' => $file
40+
));
41+
}
42+
}

lib/Github/Client.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,20 @@ public function getPullRequestApi()
281281
return $this->apis['pullrequest'];
282282
}
283283

284+
/**
285+
* Get the markdown API
286+
*
287+
* @return Api\Markdown the markdown API
288+
*/
289+
public function getMarkdownApi()
290+
{
291+
if (!isset($this->apis['markdown'])) {
292+
$this->apis['markdown'] = new Api\Markdown($this);
293+
}
294+
295+
return $this->apis['markdown'];
296+
}
297+
284298
/**
285299
* Inject an API instance
286300
*

0 commit comments

Comments
 (0)