18ec9a8f2SSungbin Jeon<?php 28ec9a8f2SSungbin Jeon 38ec9a8f2SSungbin Jeonnamespace Dokuwiki\Plugin\Commonmark; 48ec9a8f2SSungbin Jeon 58ec9a8f2SSungbin Jeonuse League\CommonMark\Environment; 68ec9a8f2SSungbin Jeonuse League\CommonMark\DocParser; 7*1e536badSSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Extension\CommonmarkToDokuwikiExtension; 88ec9a8f2SSungbin Jeon 98ec9a8f2SSungbin Jeonclass Commonmark { 108ec9a8f2SSungbin Jeon public static function RendtoDW($markdown): string { 118ec9a8f2SSungbin Jeon # create environment 128ec9a8f2SSungbin Jeon $environment = self::createDWEnvironment(); 138ec9a8f2SSungbin Jeon 148ec9a8f2SSungbin Jeon # create parser 158ec9a8f2SSungbin Jeon $parser = new DocParser($environment); 168ec9a8f2SSungbin Jeon # create Dokuwiki Renderer 178ec9a8f2SSungbin Jeon $DWRenderer = new DWRenderer($environment); 188ec9a8f2SSungbin Jeon 198ec9a8f2SSungbin Jeon $document = $parser->parse($markdown); 208ec9a8f2SSungbin Jeon return $DWRenderer->renderBlock($document); 218ec9a8f2SSungbin Jeon } 228ec9a8f2SSungbin Jeon 238ec9a8f2SSungbin Jeon public static function createDWEnvironment(): Environment { 248ec9a8f2SSungbin Jeon $environment = new Environment(); 258ec9a8f2SSungbin Jeon $environment->addExtension(new CommonMarkToDokuWikiExtension()); 268ec9a8f2SSungbin Jeon 278ec9a8f2SSungbin Jeon return $environment; 288ec9a8f2SSungbin Jeon } 298ec9a8f2SSungbin Jeon} 308ec9a8f2SSungbin Jeon 318ec9a8f2SSungbin Jeon?>