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