File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change 18
18
"phpdocumentor/reflection-docblock" : " ^5.0" ,
19
19
"gitonomy/gitlib" : " ^1.2" ,
20
20
"cebe/markdown" : " ^1.2" ,
21
- "paquettg/php-html-parser " : " ^3.1 "
21
+ "voku/simple_html_dom " : " ^4.7 "
22
22
},
23
23
"autoload" : {
24
24
"psr-4" : {"PHPFUI\\ InstaDoc\\ " : " src/PHPFUI/InstaDoc/" }
Original file line number Diff line number Diff line change @@ -32,19 +32,18 @@ public function text(string $markdown) : string
32
32
$ div = new \PHPFUI \HTML5Element ('div ' );
33
33
$ div ->addClass ('markdown-body ' );
34
34
$ html = $ this ->parser ->parse ($ markdown );
35
- $ dom = new \PHPHtmlParser \Dom ();
36
- $ dom ->setOptions ((new \PHPHtmlParser \Options ())->setPreserveLineBreaks (true ));
37
- $ dom ->loadStr ($ html );
35
+ $ dom = new \voku \helper \HtmlDomParser ($ html );
38
36
$ codeBlocks = $ dom ->find ('.language-PHP ' );
37
+
39
38
foreach ($ codeBlocks as $ block )
40
39
{
41
40
$ child = $ block ->firstChild ();
42
41
$ highlighted = $ hl ->highlight ('php ' , $ child ->text ());
43
42
$ block ->setAttribute ('class ' , 'hljs ' . $ highlighted ->language );
44
- $ block ->getParent ()->setAttribute ('class ' , 'hljs ' . $ highlighted ->language );
45
- $ child ->setText ( \htmlspecialchars_decode ($ highlighted ->value ) );
43
+ $ block ->parentNode ()->setAttribute ('class ' , 'hljs ' . $ highlighted ->language );
44
+ $ child ->plainText = \htmlspecialchars_decode ($ highlighted ->value );
46
45
}
47
- $ div ->add ($ dom );
46
+ $ div ->add ("{ $ dom}" );
48
47
49
48
return $ div ;
50
49
}
You can’t perform that action at this time.
0 commit comments