1<?php
2require_once __DIR__.'/src/bootstrap.php';
3
4use Dokuwiki\Plugin\Commonmark\Commonmark;
5use League\CommonMark\CommonMarkConverter;
6
7//$environment = Environment::createCommonMarkEnvironment();
8
9//$parser = new DocParser($environment);
10//$htmlRenderer = new HtmlRenderer($environment);
11
12$test1 = '# Hello World!
13> Blockquote Test!
14> test continues
15>
16> TEST!
17>> Indented test';
18
19$test2 = '## List test
20### Unordered List
21- item 1
22- item 2
23    - item 2.1
24- item 3
25
26### Ordered List
271. item 1
282. item 2
29    1. item 2.1
303. item 3';
31
32$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.
33
34Lorem 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.
35Etiam 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.';
36
37$test4 = '```ruby
38def foo(x)
39  return 3
40end
41```
42
43    foo
44bar
45***
46```html
47<html>
48<head>
49dddd
50</head>
51</html>
52```';
53
54$test5 = '`foo`
55
56*ITALIC* **BOLD** ***BOLDITALIC*** and ~~strikethrough~~
57HARD break [yahoo](yahoo.com) <p>hello</p> <a>hello</a> ![](test.jpg)';
58
59$test6 = 'hello, its footnote and [link] test [^1] [^2].
60
61[link]: google.com
62[nolink]: facebook.com
63[^1]: footnote.com
64[^2]: secondfootnote.com
65[^3]: this is an anonymous footnote.';
66
67$test7 = '
68| Left columns  | Right columns |
69| ------------- |:-------------:|
70| left foo      | right foo     |
71| left bar      | right bar     |
72| left baz      | right baz     |
73';
74
75$test8 = ' list footnote test[^3];
76- **test**.
77- test2[^2].
78  - nested list test[^1].
79
80outside footnote test[^4].
81
82[^1]: footnote test 1.
83[^2]: footnote test 2.
84[^3]: normal text test.
85[^4]: normal text test 2.
86';
87
88$test9 = '
89Before the code
90
91```
92fenced line 1
93fenced line 2
94```
95
96    indent line 1
97    indent line 2
98
99After the code';
100
101$test10 = <<<MD
102---
103tags:
104  - tag1
105  - tag2
106---
107
108Before the code
109
110```
111fenced line 1
112fenced line 2
113```
114
115    indent line 1
116    indent line 2
117
118After the code
119MD;
120
121$test11_p = '
122---
123layout: post
124title: I Love Markdown
125tags:
126  - test
127  - example
128---
129
130# Hello World!
131It is [[wiki/link|Wikilink]].
132[wikilink](wiki/link) [external link](https://external.link)
133';
134
135$test11 = <<<MD
136$test11_p
137MD;
138
139$test12 = '
140Title
141======
142
143## List test
144### Unordered List
145- ~~item 1~~
146- **item 2**
147- item 3
148- foo
149- bar
150- ~~ baz ~~
151
152### Ordered List
1531. ~~item 1~~
1542. **item 2**
1553. item 3'
156;
157
158$test13 = 'Inline markup and punctuation: Go**Bold**, *Italic*, `fixed-width`.';
159
160$test14 = '| X | Y |
161| ----------- | ----------------- |
162| <ul><li>A<li>B<ul><li>Ba<li>Bb</ul><li>C</ul> | me |';
163
164$test15 = '
1651. Option one
166 Second paragraph
167
1682. Option two
169 Second paragraph
170
171HARD
172BREAK
173
174SOFT
175BREAK';
176
177$test = ltrim($test15);
178echo $test . "\n\n=========================\n\n";
179
180$time_start = microtime(true);
181$result = Commonmark::RendtoDW($test);
182$time_end = microtime(true);
183echo $result['text'] . "\n\n=========================\n\n";
184echo print_r($result['heading']) . "\n\n=========================\n\n";
185$converter = new CommonMarkConverter();
186echo $converter->convert($test);
187
188// ms time
189$execution_time = ($time_end - $time_start)*1000;
190
191$converter = new CommonMarkConverter();
192echo $converter->convert($test);
193
194//execution time of the script
195echo 'Total Execution Time: '.$execution_time.' ms';
196
197//$frontmatter = Commonmark::ExtractFrontmatter($test);
198//print_r($frontmatter);
199
200?>