summaryrefslogtreecommitdiff
path: root/handler/admin/MarkdownPreview.php
blob: e513709c97d739a4c133b3cf51b14b70c9b10e5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?php

namespace handler\admin;

use Response;

class MarkdownPreview extends AdminRequestHandler {

    public function post(): Response {
        list($md, $title, $use_image_previews) = $this->input('md, title, b:use_image_previews');

        $html = \markup::markdownToHtml($md, $use_image_previews);

        $ctx = new \SkinContext('\\skin\\admin');
        $html = $ctx->markdownPreview(
            unsafe_html: $html,
            title: $title
        );
        return new \AjaxOkResponse(['html' => $html]);
    }

}