X-Git-Url: https://git.bts.cx/cx.git/blobdiff_plain/c469f0f84d54065f375698e891da3461abaf661f..a33491c3a25cf858b67f279c10d93e0eb863ad92:/cx/lib/markdown.php diff --git a/cx/lib/markdown.php b/cx/lib/markdown.php new file mode 100644 index 0000000..8cdc235 --- /dev/null +++ b/cx/lib/markdown.php @@ -0,0 +1,41 @@ +InlineTypes['{'][]= 'BlogImage'; + $this->inlineMarkerList .= '{'; + } + + protected function inlineBlogImage($excerpt) { + if (preg_match('/^{img:([^}]+)}/', $excerpt['text'], $matches)) { + $image_id = $matches[1]; + $image = cx_images_find_image($image_id); + + if ($image == null) { + return; + } + + $permalink = '/data/images/' . $image->url; + + return array( + 'extent' => strlen($matches[0]) + 1, + 'element' => array( + 'name' => 'img', + 'attributes' => array( + 'src' => cx_url($permalink), + 'alt' => $image->alt_text, + ), + ), + ); + } + } +} + +function cx_markdown_generate_html($markdown) { + static $Parsedown = new ExtendedParsedown(); + return $Parsedown->text($markdown); +}