-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
39 lines (36 loc) · 1.35 KB
/
test.php
File metadata and controls
39 lines (36 loc) · 1.35 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
<?php
$_=<<<'COMMWNT'
?= '<!DOCTYPE html><title>BBCode parser</title><style>body{font-family: monospace}</style>' .
'<style>a:visited,a:link{color:blue;}a:hover{color:orangered;}a:active{color:black;}</style>';
require_once 'BBcode.php';
use BBCode\BBCode;
use function BBCode\htmlspecialchars12;
use function BBCode\json_fromArray;
// this file is for backwards compatibility with my site, you may copy it,
// but not edit it to the repository, otherwise feel free to use this too.
$COMPOUND = <<<'BBCODE'
before-begin
[h1]Hello.spec[/h1]
[p start=here]Hello.spec
outerHTML
BBCODE. "\nafter-end";
$bbcode = new BBCode("<$COMPOUND>");
$outerHTML = (function (string $name, array $attributes, string $children, string $else): string {
return $else;
});/*addparseModes([
'pre:pre' => [
'closure' => (function (string $string, string $char): string {
return match ($char) {
"\n", "\\n" => "{$string}[br/]",
'[', ']' => "$string\\$char",
//' ' => "$string ",
default => "$string$char",
};
}), 'start' => '[code]', 'end' => '[/code]',
],
]->)*/
//echo "\n<pre>";
//ob_start('BBCode\\htmlspecialchars12');
echo "\n<pre>" . htmlspecialchars12($bbcode->parse()->toHTML()) . "</pre>";
echo "\n\n<pre>" . htmlspecialchars12(json_fromArray($bbcode->toArray()));
COMMWNT;