Grav\Plugin\Admin\AdminController::taskProcessMarkdown PHP Method

taskProcessMarkdown() protected method

Process the page Markdown
protected taskProcessMarkdown ( ) : boolean
return boolean True if the action was performed.
    protected function taskProcessMarkdown()
    {
        /*if (!$this->authorizeTask('process markdown', ['admin.pages', 'admin.super'])) {
              return;
          }*/
        try {
            $page = $this->admin->page(true);
            if (!$page) {
                $this->admin->json_response = ['status' => 'error', 'message' => $this->admin->translate('PLUGIN_ADMIN.NO_PAGE_FOUND')];
                return false;
            }
            $this->preparePage($page, true);
            $page->header();
            // Add theme template paths to Twig loader
            $template_paths = $this->grav['locator']->findResources('theme://templates');
            $this->grav['twig']->twig->getLoader()->addLoader(new \Twig_Loader_Filesystem($template_paths));
            $html = $page->content();
            $this->admin->json_response = ['status' => 'success', 'preview' => $html];
        } catch (\Exception $e) {
            $this->admin->json_response = ['status' => 'error', 'message' => $e->getMessage()];
            return false;
        }
        return true;
    }