xref: /plugin/commonmark/action.php (revision 8ec9a8f2fa8d03e80395a040a2626880092b4ddf)
1<?php
2/**
3 * Commonmark Plugin test
4 */
5error_reporting(E_ALL);
6ini_set("display_errors", 1);
7
8 require_once __DIR__.'/src/bootstrap.php';
9
10 use Dokuwiki\Plugin\Commonmark\Commonmark;
11
12 if(!defined('DOKU_INC')) die();
13
14 class action_plugin_commonmark extends DokuWiki_Action_Plugin {
15    /**
16     * pass text to Commonmark parser before DW parser
17     */
18    public function register(Doku_Event_Handler $controller) {
19        $controller->register_hook('PARSER_WIKITEXT_PREPROCESS', 'BEFORE', $this,
20                                   '_commonmarkparse');
21    }
22
23    /**
24     * Parse commonmark text
25     * TEST: <!DOCTYPE markdown> to "PASSED!!"
26     */
27    public function _commonmarkparse(Doku_Event $event, $param) {
28        if (preg_match('/\A<!DOCTYPE markdown>/',$event->data)) {
29            $event->data = Commonmark::RendtoDW(preg_replace('/\A<!DOCTYPE markdown>/','',$event->data));
30            #$event->data = "PASSED";
31        }
32
33    }
34
35}