Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/manuwhat/strip-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
manuwhat committed Jun 22, 2019
2 parents b418291 + 80b5977 commit 57da0ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/beforeStrip.php
Expand Up @@ -17,17 +17,17 @@ public function __construct($html)
if (!is_string($html)) {
throw new \InvalidArgumentException(sprintf('Waiting string, %s given', gettype($html)));
}
$html=is_file($html)?file_get_contents($html):$html;
$html=is_file($html) ?file_get_contents($html) : $html;
$this->setMainTags($html);

$html='<div>'.str_replace(
array($this->doctype,$this->html_tag,'</html>',$this->head,'</head>',$this->body,'</body>'),
array('<doctypetag '.substr($this->doctype, 10),'<htmltag '.substr($this->html_tag, 5),'</htmltag>','<headtag '.substr($this->head, 5),'</headtag>','<bodytag '.substr($this->body, 5),'</bodytag>'),
array($this->doctype, $this->html_tag, '</html>', $this->head, '</head>', $this->body, '</body>'),
array('<doctypetag '.substr($this->doctype, 10), '<htmltag '.substr($this->html_tag, 5), '</htmltag>', '<headtag '.substr($this->head, 5), '</headtag>', '<bodytag '.substr($this->body, 5), '</bodytag>'),
$html
).'</doctypetag></div>';
$preprocessed=token_get_all($html);

$HTML=array_filter($preprocessed, function ($v) {
$HTML=array_filter($preprocessed, function($v) {
return is_array($v)&&$v[0]===T_INLINE_HTML;
});
$PHP=array_diff_key($preprocessed, $HTML);
Expand Down Expand Up @@ -59,8 +59,8 @@ protected function setMainTags(&$html)
}
protected function init(&$HTML, &$PHP, &$html)
{
list($is_h, $is_p)=array((bool)$HTML,(bool)$PHP);
list($this->is_html, $this->is_php, $this->multi, $this->content, $this->html, $this->php)=array($is_h,$is_p,$is_h&&$is_p,$html,$is_p?$HTML:array(),$is_p?$PHP:array());
list($is_h, $is_p)=array((bool)$HTML, (bool)$PHP);
list($this->is_html, $this->is_php, $this->multi, $this->content, $this->html, $this->php)=array($is_h, $is_p, $is_h&&$is_p, $html, $is_p ? $HTML : array(), $is_p ? $PHP : array());
}

public function mustLoadMulti()
Expand Down
12 changes: 6 additions & 6 deletions src/prepareStrip.php
Expand Up @@ -2,7 +2,7 @@
namespace EZAMA{
class prepareStrip
{
protected $state ;
protected $state;
protected $preprocessed;
public function __construct(beforeStrip $prepocessed)
{
Expand All @@ -19,21 +19,21 @@ public function getPrepared()
if ($this->state==='single') {
return $this->prepocessed->getContent();
}
$prepared=$this->preparePhp() + $this->prepareHtml();
$prepared=$this->preparePhp()+$this->prepareHtml();
ksort($prepared);
return join('', $prepared);
}

public function prepareHtml()
{
return array_map(function ($v) {
return is_array($v)?$v[1]:$v;
return array_map(function($v) {
return is_array($v) ? $v[1] : $v;
}, $this->prepocessed->getHTML());
}
public function preparePhp()
{
return array_map(function ($v) {
return is_array($v)&&($v[0]===T_OPEN_TAG||$v[0]===T_CLOSE_TAG)?($v[0]===T_OPEN_TAG?'<php>':'</php>'):(is_array($v)?$v[1]:$v);
return array_map(function($v) {
return is_array($v)&&($v[0]===T_OPEN_TAG||$v[0]===T_CLOSE_TAG) ? ($v[0]===T_OPEN_TAG ? '<php>' : '</php>') : (is_array($v) ? $v[1] : $v);
}, $this->prepocessed->getPHP());
}
}
Expand Down

0 comments on commit 57da0ba

Please sign in to comment.