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