public static function formatHtml($input, $preview = false) { $result = Markdown::parse(trim($input)); if ($preview) { $result = str_replace('<pre>', '<pre class="prettyprint">', $result); } $result = TagProcessor::instance()->processTags($result, $preview); return $result; }
/** * Register method, called when the plugin is first registered. */ public function register() { /* * Register the image tag processing callback */ TagProcessor::instance()->registerCallback(function ($input, $preview) { if (!$preview) { return $input; } return preg_replace('|\\<img alt="([0-9]+)" src="image"([^>]*)\\/>|m', '<span class="image-placeholder" data-index="$1"> <span class="upload-dropzone"> <span class="label">Click or drop an image...</span> <span class="indicator"></span> </span> </span>', $input); }); }
/** * Register method, called when the plugin is first registered. */ public function register() { PostsController::extend(function ($controller) { $controller->addJs('/plugins/rainlab/blogvideo/assets/js/blog-video.js'); $controller->addCss('/plugins/rainlab/blogvideo/assets/css/blog-video.css'); }); /* * Register the video tag processing callback */ TagProcessor::instance()->registerCallback(function ($input, $preview) { if (!$preview) { return $input; } $popup = file_get_contents(__DIR__ . '/partials/popup.htm'); return preg_replace('|\\<img alt="([0-9]+)" src="video" \\/>|m', '<span class="video-placeholder" data-index="$1"> <a href="#">Click to embed a video...</a> ' . $popup . ' </span>', $input); }); }