18ec9a8f2SSungbin Jeon<?php 28ec9a8f2SSungbin Jeonrequire_once __DIR__.'/src/bootstrap.php'; 38ec9a8f2SSungbin Jeon 48ec9a8f2SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Commonmark; 58f24791eSSungbin Jeonuse League\CommonMark\CommonMarkConverter; 68ec9a8f2SSungbin Jeon 78ec9a8f2SSungbin Jeon//$environment = Environment::createCommonMarkEnvironment(); 88ec9a8f2SSungbin Jeon 98ec9a8f2SSungbin Jeon//$parser = new DocParser($environment); 108ec9a8f2SSungbin Jeon//$htmlRenderer = new HtmlRenderer($environment); 118ec9a8f2SSungbin Jeon 128ec9a8f2SSungbin Jeon$test1 = '# Hello World! 138ec9a8f2SSungbin Jeon> Blockquote Test! 148ec9a8f2SSungbin Jeon> test continues 158ec9a8f2SSungbin Jeon> 168ec9a8f2SSungbin Jeon> TEST! 178ec9a8f2SSungbin Jeon>> Indented test'; 188ec9a8f2SSungbin Jeon 198ec9a8f2SSungbin Jeon$test2 = '## List test 208ec9a8f2SSungbin Jeon### Unordered List 218ec9a8f2SSungbin Jeon- item 1 228ec9a8f2SSungbin Jeon- item 2 238ec9a8f2SSungbin Jeon - item 2.1 248ec9a8f2SSungbin Jeon- item 3 258ec9a8f2SSungbin Jeon 268ec9a8f2SSungbin Jeon### Ordered List 278ec9a8f2SSungbin Jeon1. item 1 288ec9a8f2SSungbin Jeon2. item 2 298ec9a8f2SSungbin Jeon 1. item 2.1 308ec9a8f2SSungbin Jeon3. item 3'; 318ec9a8f2SSungbin Jeon 328ec9a8f2SSungbin Jeon$test3 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a iaculis augue. Donec condimentum velit elit, et suscipit sem mattis ac. Duis consequat, velit a lobortis tempor, lorem elit accumsan sapien, sed consectetur mauris neque non erat. Aliquam erat volutpat. Nam posuere et sapien eu lobortis. Praesent fringilla ipsum non velit vulputate, ac pulvinar velit ultrices. Etiam neque massa, venenatis in placerat id, iaculis eu turpis. Sed interdum gravida odio quis porttitor. Nunc vestibulum facilisis ultrices. Ut ultricies, tortor a bibendum sodales, diam mi commodo nibh, non tincidunt nibh erat eget leo. Proin ac lorem eget libero semper consectetur. Phasellus bibendum neque erat, ac egestas nunc varius at. Integer eu ante tristique, semper erat eget, faucibus eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam imperdiet sollicitudin urna non maximus. Pellentesque tortor erat, pulvinar in mauris non, luctus ullamcorper nibh. 338ec9a8f2SSungbin Jeon 348ec9a8f2SSungbin JeonLorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque a iaculis augue. Donec condimentum velit elit, et suscipit sem mattis ac. Duis consequat, velit a lobortis tempor, lorem elit accumsan sapien, sed consectetur mauris neque non erat. Aliquam erat volutpat. Nam posuere et sapien eu lobortis. Praesent fringilla ipsum non velit vulputate, ac pulvinar velit ultrices. 358ec9a8f2SSungbin JeonEtiam neque massa, venenatis in placerat id, iaculis eu turpis. Sed interdum gravida odio quis porttitor. Nunc vestibulum facilisis ultrices. Ut ultricies, tortor a bibendum sodales, diam mi commodo nibh, non tincidunt nibh erat eget leo. Proin ac lorem eget libero semper consectetur. Phasellus bibendum neque erat, ac egestas nunc varius at. Integer eu ante tristique, semper erat eget, faucibus eros. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam imperdiet sollicitudin urna non maximus. Pellentesque tortor erat, pulvinar in mauris non, luctus ullamcorper nibh.'; 368ec9a8f2SSungbin Jeon 378ec9a8f2SSungbin Jeon$test4 = '```ruby 388ec9a8f2SSungbin Jeondef foo(x) 398ec9a8f2SSungbin Jeon return 3 408ec9a8f2SSungbin Jeonend 418ec9a8f2SSungbin Jeon``` 428ec9a8f2SSungbin Jeon 438ec9a8f2SSungbin Jeon foo 448ec9a8f2SSungbin Jeonbar 458ec9a8f2SSungbin Jeon*** 468ec9a8f2SSungbin Jeon```html 478ec9a8f2SSungbin Jeon<html> 488ec9a8f2SSungbin Jeon<head> 498ec9a8f2SSungbin Jeondddd 508ec9a8f2SSungbin Jeon</head> 518ec9a8f2SSungbin Jeon</html> 528ec9a8f2SSungbin Jeon```'; 538ec9a8f2SSungbin Jeon 548ec9a8f2SSungbin Jeon$test5 = '`foo` 558ec9a8f2SSungbin Jeon 5678c882e7SSungbin Jeon*ITALIC* **BOLD** ***BOLDITALIC*** and ~~strikethrough~~ 578ec9a8f2SSungbin JeonHARD break [yahoo](yahoo.com) <p>hello</p> <a>hello</a> '; 588ec9a8f2SSungbin Jeon 59f46768a8SSungbin Jeon$test6 = 'hello, its footnote and [link] test [^1] [^2]. 60f46768a8SSungbin Jeon 61f46768a8SSungbin Jeon[link]: google.com 62f46768a8SSungbin Jeon[nolink]: facebook.com 63f46768a8SSungbin Jeon[^1]: footnote.com 64f46768a8SSungbin Jeon[^2]: secondfootnote.com 65f46768a8SSungbin Jeon[^3]: this is an anonymous footnote.'; 66f46768a8SSungbin Jeon 671adb3ebeSSungbin Jeon$test7 = ' 681adb3ebeSSungbin Jeon| Left columns | Right columns | 691adb3ebeSSungbin Jeon| ------------- |:-------------:| 701adb3ebeSSungbin Jeon| left foo | right foo | 711adb3ebeSSungbin Jeon| left bar | right bar | 721adb3ebeSSungbin Jeon| left baz | right baz | 731adb3ebeSSungbin Jeon'; 741adb3ebeSSungbin Jeon 75b0a36678SSungbin Jeon$test8 = ' list footnote test[^3]; 76286063f0SSungbin Jeon- **test**. 77286063f0SSungbin Jeon- test2[^2]. 78286063f0SSungbin Jeon - nested list test[^1]. 79286063f0SSungbin Jeon 80286063f0SSungbin Jeonoutside footnote test[^4]. 81286063f0SSungbin Jeon 82286063f0SSungbin Jeon[^1]: footnote test 1. 83286063f0SSungbin Jeon[^2]: footnote test 2. 84286063f0SSungbin Jeon[^3]: normal text test. 85286063f0SSungbin Jeon[^4]: normal text test 2. 86286063f0SSungbin Jeon'; 87286063f0SSungbin Jeon 88b0a36678SSungbin Jeon$test9 = ' 8994a075eeSSungbin JeonBefore the code 9094a075eeSSungbin Jeon 9194a075eeSSungbin Jeon``` 9294a075eeSSungbin Jeonfenced line 1 9394a075eeSSungbin Jeonfenced line 2 9494a075eeSSungbin Jeon``` 9594a075eeSSungbin Jeon 9694a075eeSSungbin Jeon indent line 1 9794a075eeSSungbin Jeon indent line 2 9894a075eeSSungbin Jeon 9994a075eeSSungbin JeonAfter the code'; 10094a075eeSSungbin Jeon 10181da5a38SSungbin Jeon$test10 = <<<MD 10281da5a38SSungbin Jeon--- 10381da5a38SSungbin Jeontags: 10481da5a38SSungbin Jeon - tag1 10581da5a38SSungbin Jeon - tag2 10681da5a38SSungbin Jeon--- 1078ec9a8f2SSungbin Jeon 10881da5a38SSungbin JeonBefore the code 10981da5a38SSungbin Jeon 11081da5a38SSungbin Jeon``` 11181da5a38SSungbin Jeonfenced line 1 11281da5a38SSungbin Jeonfenced line 2 11381da5a38SSungbin Jeon``` 11481da5a38SSungbin Jeon 11581da5a38SSungbin Jeon indent line 1 11681da5a38SSungbin Jeon indent line 2 11781da5a38SSungbin Jeon 11881da5a38SSungbin JeonAfter the code 11981da5a38SSungbin JeonMD; 12081da5a38SSungbin Jeon 1217569cca4SSungbin Jeon$test11_p = ' 1227569cca4SSungbin Jeon--- 12381da5a38SSungbin Jeonlayout: post 12481da5a38SSungbin Jeontitle: I Love Markdown 12581da5a38SSungbin Jeontags: 12681da5a38SSungbin Jeon - test 12781da5a38SSungbin Jeon - example 12881da5a38SSungbin Jeon--- 12981da5a38SSungbin Jeon 13081da5a38SSungbin Jeon# Hello World! 131ac4825fcSSungbin JeonIt is [[wiki/link|Wikilink]]. 132ac4825fcSSungbin Jeon[wikilink](wiki/link) [external link](https://external.link) 1334384789bSSungbin Jeon'; 1344384789bSSungbin Jeon 1354384789bSSungbin Jeon$test11 = <<<MD 1364384789bSSungbin Jeon$test11_p 13781da5a38SSungbin JeonMD; 13881da5a38SSungbin Jeon 13980734199SSungbin Jeon$test12 = ' 14080734199SSungbin JeonTitle 14180734199SSungbin Jeon====== 14280734199SSungbin Jeon 14380734199SSungbin Jeon## List test 144d524ef1aSDominik Meißner### Unordered List 145d524ef1aSDominik Meißner- ~~item 1~~ 146d524ef1aSDominik Meißner- **item 2** 147d524ef1aSDominik Meißner- item 3 1488f24791eSSungbin Jeon- foo 1498f24791eSSungbin Jeon- bar 1508f24791eSSungbin Jeon- ~~ baz ~~ 151d524ef1aSDominik Meißner 152d524ef1aSDominik Meißner### Ordered List 153d524ef1aSDominik Meißner1. ~~item 1~~ 154d524ef1aSDominik Meißner2. **item 2** 1558f24791eSSungbin Jeon3. item 3' 1568f24791eSSungbin Jeon; 157d524ef1aSDominik Meißner 1588f24791eSSungbin Jeon$test13 = 'Inline markup and punctuation: Go**Bold**, *Italic*, `fixed-width`.'; 15904daf66eSAdrien Beau 1608f24791eSSungbin Jeon$test14 = '| X | Y | 1618f24791eSSungbin Jeon| ----------- | ----------------- | 1628f24791eSSungbin Jeon| <ul><li>A<li>B<ul><li>Ba<li>Bb</ul><li>C</ul> | me |'; 1638f24791eSSungbin Jeon 164*7dbe6b57SSungbin Jeon$test15 = ' 165*7dbe6b57SSungbin Jeon1. Option one 166*7dbe6b57SSungbin Jeon Second paragraph 167*7dbe6b57SSungbin Jeon 168*7dbe6b57SSungbin Jeon2. Option two 169*7dbe6b57SSungbin Jeon Second paragraph 170*7dbe6b57SSungbin Jeon 171*7dbe6b57SSungbin JeonHARD 172*7dbe6b57SSungbin JeonBREAK 173*7dbe6b57SSungbin Jeon 174*7dbe6b57SSungbin JeonSOFT 175*7dbe6b57SSungbin JeonBREAK'; 176*7dbe6b57SSungbin Jeon 177*7dbe6b57SSungbin Jeon$test = ltrim($test15); 17881da5a38SSungbin Jeonecho $test . "\n\n=========================\n\n"; 179*7dbe6b57SSungbin Jeon 180*7dbe6b57SSungbin Jeon$time_start = microtime(true); 181*7dbe6b57SSungbin Jeon$result = Commonmark::RendtoDW($test); 182*7dbe6b57SSungbin Jeon$time_end = microtime(true); 183*7dbe6b57SSungbin Jeonecho $result['text'] . "\n\n=========================\n\n"; 184*7dbe6b57SSungbin Jeonecho print_r($result['heading']) . "\n\n=========================\n\n"; 1858f24791eSSungbin Jeon$converter = new CommonMarkConverter(); 1868f24791eSSungbin Jeonecho $converter->convert($test); 1878f24791eSSungbin Jeon 188*7dbe6b57SSungbin Jeon// ms time 189*7dbe6b57SSungbin Jeon$execution_time = ($time_end - $time_start)*1000; 190*7dbe6b57SSungbin Jeon 191*7dbe6b57SSungbin Jeon$converter = new CommonMarkConverter(); 192*7dbe6b57SSungbin Jeonecho $converter->convert($test); 193*7dbe6b57SSungbin Jeon 194*7dbe6b57SSungbin Jeon//execution time of the script 195*7dbe6b57SSungbin Jeonecho 'Total Execution Time: '.$execution_time.' ms'; 196*7dbe6b57SSungbin Jeon 197ac4825fcSSungbin Jeon//$frontmatter = Commonmark::ExtractFrontmatter($test); 198ac4825fcSSungbin Jeon//print_r($frontmatter); 19980734199SSungbin Jeon 2008ec9a8f2SSungbin Jeon?>