xref: /plugin/commonmark/DWtest.php (revision 80734199223681576dd58b9113e35ae4786f6692)
18ec9a8f2SSungbin Jeon<?php
28ec9a8f2SSungbin Jeon
38ec9a8f2SSungbin Jeonrequire_once __DIR__.'/src/bootstrap.php';
48ec9a8f2SSungbin Jeon
58ec9a8f2SSungbin Jeonuse Dokuwiki\Plugin\Commonmark\Commonmark;
68f24791eSSungbin Jeonuse League\CommonMark\CommonMarkConverter;
78ec9a8f2SSungbin Jeon
88ec9a8f2SSungbin Jeon//$environment = Environment::createCommonMarkEnvironment();
98ec9a8f2SSungbin Jeon
108ec9a8f2SSungbin Jeon//$parser = new DocParser($environment);
118ec9a8f2SSungbin Jeon//$htmlRenderer = new HtmlRenderer($environment);
128ec9a8f2SSungbin Jeon
138ec9a8f2SSungbin Jeon$test1 = '# Hello World!
148ec9a8f2SSungbin Jeon> Blockquote Test!
158ec9a8f2SSungbin Jeon> test continues
168ec9a8f2SSungbin Jeon>
178ec9a8f2SSungbin Jeon> TEST!
188ec9a8f2SSungbin Jeon>> Indented test';
198ec9a8f2SSungbin Jeon
208ec9a8f2SSungbin Jeon$test2 = '## List test
218ec9a8f2SSungbin Jeon### Unordered List
228ec9a8f2SSungbin Jeon- item 1
238ec9a8f2SSungbin Jeon- item 2
248ec9a8f2SSungbin Jeon    - item 2.1
258ec9a8f2SSungbin Jeon- item 3
268ec9a8f2SSungbin Jeon
278ec9a8f2SSungbin Jeon### Ordered List
288ec9a8f2SSungbin Jeon1. item 1
298ec9a8f2SSungbin Jeon2. item 2
308ec9a8f2SSungbin Jeon    1. item 2.1
318ec9a8f2SSungbin Jeon3. item 3';
328ec9a8f2SSungbin Jeon
338ec9a8f2SSungbin 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.
348ec9a8f2SSungbin Jeon
358ec9a8f2SSungbin 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.
368ec9a8f2SSungbin 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.';
378ec9a8f2SSungbin Jeon
388ec9a8f2SSungbin Jeon$test4 = '```ruby
398ec9a8f2SSungbin Jeondef foo(x)
408ec9a8f2SSungbin Jeon  return 3
418ec9a8f2SSungbin Jeonend
428ec9a8f2SSungbin Jeon```
438ec9a8f2SSungbin Jeon
448ec9a8f2SSungbin Jeon    foo
458ec9a8f2SSungbin Jeonbar
468ec9a8f2SSungbin Jeon***
478ec9a8f2SSungbin Jeon```html
488ec9a8f2SSungbin Jeon<html>
498ec9a8f2SSungbin Jeon<head>
508ec9a8f2SSungbin Jeondddd
518ec9a8f2SSungbin Jeon</head>
528ec9a8f2SSungbin Jeon</html>
538ec9a8f2SSungbin Jeon```';
548ec9a8f2SSungbin Jeon
558ec9a8f2SSungbin Jeon$test5 = '`foo`
568ec9a8f2SSungbin Jeon
5778c882e7SSungbin Jeon*ITALIC* **BOLD** ***BOLDITALIC*** and ~~strikethrough~~
588ec9a8f2SSungbin JeonHARD break [yahoo](yahoo.com) <p>hello</p> <a>hello</a> ![](test.jpg)';
598ec9a8f2SSungbin Jeon
60f46768a8SSungbin Jeon$test6 = 'hello, its footnote and [link] test [^1] [^2].
61f46768a8SSungbin Jeon
62f46768a8SSungbin Jeon[link]: google.com
63f46768a8SSungbin Jeon[nolink]: facebook.com
64f46768a8SSungbin Jeon[^1]: footnote.com
65f46768a8SSungbin Jeon[^2]: secondfootnote.com
66f46768a8SSungbin Jeon[^3]: this is an anonymous footnote.';
67f46768a8SSungbin Jeon
681adb3ebeSSungbin Jeon$test7 = '
691adb3ebeSSungbin Jeon| Left columns  | Right columns |
701adb3ebeSSungbin Jeon| ------------- |:-------------:|
711adb3ebeSSungbin Jeon| left foo      | right foo     |
721adb3ebeSSungbin Jeon| left bar      | right bar     |
731adb3ebeSSungbin Jeon| left baz      | right baz     |
741adb3ebeSSungbin Jeon';
751adb3ebeSSungbin Jeon
76b0a36678SSungbin Jeon$test8 = ' list footnote test[^3];
77286063f0SSungbin Jeon- **test**.
78286063f0SSungbin Jeon- test2[^2].
79286063f0SSungbin Jeon  - nested list test[^1].
80286063f0SSungbin Jeon
81286063f0SSungbin Jeonoutside footnote test[^4].
82286063f0SSungbin Jeon
83286063f0SSungbin Jeon[^1]: footnote test 1.
84286063f0SSungbin Jeon[^2]: footnote test 2.
85286063f0SSungbin Jeon[^3]: normal text test.
86286063f0SSungbin Jeon[^4]: normal text test 2.
87286063f0SSungbin Jeon';
88286063f0SSungbin Jeon
89b0a36678SSungbin Jeon$test9 = '
9094a075eeSSungbin JeonBefore the code
9194a075eeSSungbin Jeon
9294a075eeSSungbin Jeon```
9394a075eeSSungbin Jeonfenced line 1
9494a075eeSSungbin Jeonfenced line 2
9594a075eeSSungbin Jeon```
9694a075eeSSungbin Jeon
9794a075eeSSungbin Jeon    indent line 1
9894a075eeSSungbin Jeon    indent line 2
9994a075eeSSungbin Jeon
10094a075eeSSungbin JeonAfter the code';
10194a075eeSSungbin Jeon
10281da5a38SSungbin Jeon$test10 = <<<MD
10381da5a38SSungbin Jeon---
10481da5a38SSungbin Jeontags:
10581da5a38SSungbin Jeon  - tag1
10681da5a38SSungbin Jeon  - tag2
10781da5a38SSungbin Jeon---
1088ec9a8f2SSungbin Jeon
10981da5a38SSungbin JeonBefore the code
11081da5a38SSungbin Jeon
11181da5a38SSungbin Jeon```
11281da5a38SSungbin Jeonfenced line 1
11381da5a38SSungbin Jeonfenced line 2
11481da5a38SSungbin Jeon```
11581da5a38SSungbin Jeon
11681da5a38SSungbin Jeon    indent line 1
11781da5a38SSungbin Jeon    indent line 2
11881da5a38SSungbin Jeon
11981da5a38SSungbin JeonAfter the code
12081da5a38SSungbin JeonMD;
12181da5a38SSungbin Jeon
1227569cca4SSungbin Jeon$test11_p = '
1237569cca4SSungbin Jeon---
12481da5a38SSungbin Jeonlayout: post
12581da5a38SSungbin Jeontitle: I Love Markdown
12681da5a38SSungbin Jeontags:
12781da5a38SSungbin Jeon  - test
12881da5a38SSungbin Jeon  - example
12981da5a38SSungbin Jeon---
13081da5a38SSungbin Jeon
13181da5a38SSungbin Jeon# Hello World!
132ac4825fcSSungbin JeonIt is [[wiki/link|Wikilink]].
133ac4825fcSSungbin Jeon[wikilink](wiki/link) [external link](https://external.link)
1344384789bSSungbin Jeon';
1354384789bSSungbin Jeon
1364384789bSSungbin Jeon$test11 = <<<MD
1374384789bSSungbin Jeon$test11_p
13881da5a38SSungbin JeonMD;
13981da5a38SSungbin Jeon
140*80734199SSungbin Jeon$test12 = '
141*80734199SSungbin JeonTitle
142*80734199SSungbin Jeon======
143*80734199SSungbin Jeon
144*80734199SSungbin Jeon## List test
145d524ef1aSDominik Meißner### Unordered List
146d524ef1aSDominik Meißner- ~~item 1~~
147d524ef1aSDominik Meißner- **item 2**
148d524ef1aSDominik Meißner- item 3
1498f24791eSSungbin Jeon- foo
1508f24791eSSungbin Jeon- bar
1518f24791eSSungbin Jeon- ~~ baz ~~
152d524ef1aSDominik Meißner
153d524ef1aSDominik Meißner### Ordered List
154d524ef1aSDominik Meißner1. ~~item 1~~
155d524ef1aSDominik Meißner2. **item 2**
1568f24791eSSungbin Jeon3. item 3'
1578f24791eSSungbin Jeon;
158d524ef1aSDominik Meißner
1598f24791eSSungbin Jeon$test13 = 'Inline markup and punctuation: Go**Bold**, *Italic*, `fixed-width`.';
16004daf66eSAdrien Beau
1618f24791eSSungbin Jeon$test14 = '| X | Y |
1628f24791eSSungbin Jeon| ----------- | ----------------- |
1638f24791eSSungbin Jeon| <ul><li>A<li>B<ul><li>Ba<li>Bb</ul><li>C</ul> | me |';
1648f24791eSSungbin Jeon
165*80734199SSungbin Jeon$test = ltrim($test12);
16681da5a38SSungbin Jeonecho $test . "\n\n=========================\n\n";
167*80734199SSungbin Jeon$result = Commonmark::RendtoDW($test)['text'];
1688f24791eSSungbin Jeonecho $result . "\n\n=========================\n\n";
169*80734199SSungbin Jeon$headingInfo = Commonmark::RendtoDW($test)['heading'];
170*80734199SSungbin Jeonecho print_r($headingInfo) . "\n\n=========================\n\n";
1718f24791eSSungbin Jeon$converter = new CommonMarkConverter();
1728f24791eSSungbin Jeonecho $converter->convert($test);
1738f24791eSSungbin Jeon
174ac4825fcSSungbin Jeon//$frontmatter = Commonmark::ExtractFrontmatter($test);
175ac4825fcSSungbin Jeon//print_r($frontmatter);
176*80734199SSungbin Jeon
1778ec9a8f2SSungbin Jeon?>