X-Git-Url: https://git.bts.cx/cx.git/blobdiff_plain/eb6721b2250c796d202a16d4f9d01398b2acabe2..refs/heads/mainline:/cx/lib/markdown.php diff --git a/cx/lib/markdown.php b/cx/lib/markdown.php index 00d46c2..aab58d5 100644 --- a/cx/lib/markdown.php +++ b/cx/lib/markdown.php @@ -6,7 +6,8 @@ cx_require('third_party', 'parsedown', 'Parsedown.php'); class ExtendedParsedown extends Parsedown { public function __construct() { - $this->InlineTypes['{'][]= 'BlogImage'; + $this->InlineTypes['{'][] = 'BlogImage'; + $this->InlineTypes['{'][] = 'Youtube'; $this->inlineMarkerList .= '{'; } @@ -33,6 +34,35 @@ class ExtendedParsedown extends Parsedown { ); } } + + protected function inlineYoutube($excerpt) { + if (preg_match('/^{yt:([^}]+)}/', $excerpt['text'], $matches)) { + $video_id = $matches[1]; + + if ($video_id == null) { + return; + } + + return array( + 'extent' => strlen($matches[0]) + 1, + 'element' => array( + 'name' => 'iframe', + 'text' => '', + 'attributes' => array( + 'class' => "video", + 'type' => "text/html", + //'width' => "640", + //'height' => "360", + 'src' => "https://www.youtube.com/embed/" . $video_id, + 'frameborder' => "0", + 'loading' => "lazy", + 'referrerpolicy' => "no-referrer", + 'sandbox' => "allow-same-origin allow-scripts", + ), + ), + ); + } + } } function cx_markdown_generate_html($markdown) {