Skip to content

Commit 20bcd65

Browse files
committed
Removed code that removed <code> tag
fixes paquettg#60
1 parent 01a9e2f commit 20bcd65

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/PHPHtmlParser/Dom.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ protected function clean($str)
390390
$str = mb_eregi_replace("<\s*style\s*>(.*?)<\s*/\s*style\s*>", '', $str);
391391
}
392392

393-
// strip out preformatted tags
394-
$str = mb_eregi_replace("<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>", '', $str);
395-
396393
// strip out server side scripts
397394
$str = mb_eregi_replace("(<\?)(.*?)(\?>)", '', $str);
398395

tests/DomTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,4 +302,11 @@ public function testBeforeClosingTag()
302302
$dom->load("<div class=\"stream-container \" > <div class=\"stream-item js-new-items-bar-container\"> </div> <div class=\"stream\">");
303303
$this->assertEquals("<div class=\"stream-container \"> <div class=\"stream-item js-new-items-bar-container\"> </div> <div class=\"stream\"></div></div>", (string) $dom);
304304
}
305+
306+
public function testCodeTag()
307+
{
308+
$dom = new Dom;
309+
$dom->load('<strong>hello</strong><code class="language-php">$foo = "bar";</code>');
310+
$this->assertEquals('<strong>hello</strong><code class="language-php">$foo = "bar";</code>', (string) $dom);
311+
}
305312
}

0 commit comments

Comments
 (0)