]>
git.bts.cx Git - cx.git/blob - cx/lib/markdown.php
00d46c29f64dd3d54dc257d6818f9fbd357714b9
3 cx_require('lib', 'images.php');
4 cx_require('lib', 'url.php');
5 cx_require('third_party', 'parsedown', 'Parsedown.php');
7 class ExtendedParsedown
extends Parsedown
{
8 public function __construct() {
9 $this->InlineTypes
['{'][]= 'BlogImage';
10 $this->inlineMarkerList
.= '{';
13 protected function inlineBlogImage($excerpt) {
14 if (preg_match('/^{img:([^}]+)}/', $excerpt['text'], $matches)) {
15 $image_id = $matches[1];
16 $image = cx_images_find_image($image_id);
22 $permalink = '/data/images/' . $image->url
;
25 'extent' => strlen($matches[0]) +
1,
28 'attributes' => array(
29 'src' => cx_url_site($permalink),
30 'alt' => $image->alt_text
,
38 function cx_markdown_generate_html($markdown) {
39 static $Parsedown = new ExtendedParsedown();
40 return $Parsedown->text($markdown);