Changeset View
Changeset View
Standalone View
Standalone View
src/parser/html/PhutilHTMLParser.php
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Lines | foreach ($parts as $part) { | ||||
$content = $part['content']; | $content = $part['content']; | ||||
// If this part is a tag, restore the angle brackets. | // If this part is a tag, restore the angle brackets. | ||||
if ($part['tag']) { | if ($part['tag']) { | ||||
$content = '<'.$content.'>'; | $content = '<'.$content.'>'; | ||||
} | } | ||||
$node = id(new PhutilDOMNode()) | $node = (new PhutilDOMNode()) | ||||
->setContent($content) | ->setContent($content) | ||||
->setRawHead($content); | ->setRawHead($content); | ||||
$this->getCursor()->appendChild($node); | $this->getCursor()->appendChild($node); | ||||
} | } | ||||
$root->mergeContent(); | $root->mergeContent(); | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | if (strlen($attributes)) { | ||||
// If the attributes can't be parsed, treat the tag as content. | // If the attributes can't be parsed, treat the tag as content. | ||||
if ($attribute_map === null) { | if ($attribute_map === null) { | ||||
return null; | return null; | ||||
} | } | ||||
} else { | } else { | ||||
$attribute_map = array(); | $attribute_map = array(); | ||||
} | } | ||||
$node = id(new PhutilDOMNode()) | $node = (new PhutilDOMNode()) | ||||
->setTagName($tag_name) | ->setTagName($tag_name) | ||||
->setAttributes($attribute_map) | ->setAttributes($attribute_map) | ||||
->setRawHead('<'.$raw_content.'>'); | ->setRawHead('<'.$raw_content.'>'); | ||||
$cursor = $this->getCursor(); | $cursor = $this->getCursor(); | ||||
$cursor->appendChild($node); | $cursor->appendChild($node); | ||||
if (!$self_close) { | if (!$self_close) { | ||||
▲ Show 20 Lines • Show All 213 Lines • Show Last 20 Lines |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0