18ec9a8f2SSungbin Jeon<?php 28ec9a8f2SSungbin Jeon 38ec9a8f2SSungbin Jeonnamespace Dokuwiki\Plugin\Commonmark; 48ec9a8f2SSungbin Jeon 58ec9a8f2SSungbin Jeonuse League\CommonMark\Environment; 68ec9a8f2SSungbin Jeonuse League\CommonMark\DocParser; 71e536badSSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\CommonmarkToDokuwikiExtension; 8*f46768a8SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\FootnoteToDokuwikiExtension; 98ec9a8f2SSungbin Jeon 108ec9a8f2SSungbin Jeonclass Commonmark { 118ec9a8f2SSungbin Jeon public static function RendtoDW($markdown): string { 128ec9a8f2SSungbin Jeon # create environment 138ec9a8f2SSungbin Jeon $environment = self::createDWEnvironment(); 148ec9a8f2SSungbin Jeon 158ec9a8f2SSungbin Jeon # create parser 168ec9a8f2SSungbin Jeon $parser = new DocParser($environment); 178ec9a8f2SSungbin Jeon # create Dokuwiki Renderer 188ec9a8f2SSungbin Jeon $DWRenderer = new DWRenderer($environment); 198ec9a8f2SSungbin Jeon 208ec9a8f2SSungbin Jeon $document = $parser->parse($markdown); 218ec9a8f2SSungbin Jeon return $DWRenderer->renderBlock($document); 228ec9a8f2SSungbin Jeon } 238ec9a8f2SSungbin Jeon 248ec9a8f2SSungbin Jeon public static function createDWEnvironment(): Environment { 258ec9a8f2SSungbin Jeon $environment = new Environment(); 268ec9a8f2SSungbin Jeon $environment->addExtension(new CommonMarkToDokuWikiExtension()); 27*f46768a8SSungbin Jeon $environment->addExtension(new FootnoteToDokuwikiExtension()); 28*f46768a8SSungbin Jeon 29*f46768a8SSungbin Jeon $environment->mergeConfig([ 30*f46768a8SSungbin Jeon 'html_input' => 'strip', 31*f46768a8SSungbin Jeon ]); 328ec9a8f2SSungbin Jeon 338ec9a8f2SSungbin Jeon return $environment; 348ec9a8f2SSungbin Jeon } 358ec9a8f2SSungbin Jeon} 368ec9a8f2SSungbin Jeon 378ec9a8f2SSungbin Jeon?>