设置标签名称，如a、input等
@param unknown $tagName
3152
public function setTagName($tagName)
	{
		if(is_string($tagName))
		{
			$this->tagName = $tagName;
		}
		else
		{
			$this->tagName = substr(get_called_class(),4);
		}
	}
688359
public void setTag(String tagName, int tagValue) {
    tagTable.put(tagName, Integer.valueOf(tagValue));
  }
633000
public function resolveTagNames($tagNames)
    {
        $resolvedTags = [];

        foreach ($tagNames as $tagName) {
            $tag = $this->findByName($tagName);
            if (null !== $tag) {
                $resolvedTags[] = $tag->getId();
            }
        }

        return $resolvedTags;
    }
1324021
public function updateTagsName($tagid, $name)
    {
        $queryStr = [
            'tag' => [
                'id'   => $tagid,
                'name' => $name,
            ],
        ];

        $res = $this->_post('update', $queryStr);

        return $res;
    }
736316
public function getTags($tagName = null) {
		return $this->tags->filter(function ($tag) use ($tagName) {
			return $tagName === null || $tag->getTagName() == $tagName;
		});
	}
1161483
public void setTag(String tagName, byte tagValue) {
    tagTable.put(tagName, Byte.valueOf(tagValue));
  }
759199
public function addTag(string $tagName, string $src): self
    {
        $this->tagNames[$tagName] = $src;
        return $this;
    }
1069081
public function getPropertiesByTagName($tagName)
    {
        $properties = [];

        foreach ($this->properties as $property) {
            foreach ($property->tags as $tag) {
                if ($tag['name'] == $tagName) {
                    $properties[$property->name] = $property;
                }
            }
        }

        return $properties;
    }
332963
private function _buildTag($str, $tagname)
        {
//          $tagname = $this->_options['tag_name'];
            $tag = array(
                'block'         => $str,
                'content'       => '',
                'name'          => '',
                'attributes'    => array()
            );
            $begin_len = strlen(self::$tag_open.$tagname.':');
//          echo substr($str, 0, $begin_len)."\r\n";
            if(substr($str, 0, $begin_len) !== self::$tag_open.$tagname.':')
            {
//              closing tag
                $tag['name'] = '___text';
                return $tag;
            }
            else if(substr($str, 1, 1) === '/')
            {
//              closing tag
                $tag['name'] = '---ERROR---';
                return $tag;
            }
            else
            {
//              opening tag
                $matches = array();
//              check to see if this is a full tag or an openclose tag
                $has_closing_tag = substr($tag['block'], -2) !== '/'.self::$tag_close;
//              perform data matches
                if($has_closing_tag === true)
                {
                    $preg = '!(\\'.self::$tag_open.$tagname.':([_\-A-Za-z0-9]*)[^\\'.self::$tag_close.']*\\'.self::$tag_close.'| \/\\'.self::$tag_close.').*\\'.self::$tag_open.'\/'.$tagname.':[_\-A-Za-z0-9]*\\'.self::$tag_close.'!is';
//                  $preg = '!(\<'.$tagname.':([_\-A-Za-z0-9]*)[^\>]*\>| \/\>).*\<\/'.$tagname.':[_\-A-Za-z0-9]*\>!is';
                }
                else
                {
                    $preg = '!(\\'.self::$tag_open.$tagname.':([_\-A-Za-z0-9]*)([^\\'.self::$tag_close.']*))!is';
//                  $preg = '!(\<'.$tagname.':([_\-A-Za-z0-9]*)([^\/\>]*))!is';
                }
                
                if(preg_match_all($preg, $tag['block'], $matches) > 0)
                {
//                  get the tag type
                    $tag['name']    = $matches[2][0];
                
//                  get the tag inner content
                    $tag['content'] = '';
                    $tag['vars'] = false;
                    $attribute_string = $matches[1][0];
                    if($has_closing_tag === true)
                    {
                        $begin_len      = strlen($matches[1][0]);
                        $end_len = $has_closing_tag ? strlen(self::$tag_open.'/'.$tagname.':'.$tag['name'].self::$tag_close) : 0;
                        $tag['content'] = substr($str, $begin_len, strlen($matches[0][0])-$begin_len-$end_len);
//                      get hash tags vars?
                        if($this->_options['hash_tags'] === true && preg_match_all('/#{([^}]+)?}/i', $tag['content'], $vars) > 0)
                        {                       
                            $variables = array();
                            foreach ($vars[0] as $key => $var)
                            {
                                $variables[$var] = $vars[1][$key]; 
                            }
                            $tag['vars'] = $variables;
                        }
                    }
                    else
                    {
                        $attribute_string = rtrim($attribute_string, '/ ');
                    }
                    
//                  get the attributes
                    $attributes = array();
//                  preg_match_all("/([_\-A-Za-z0-9]*)((=\"|='))([\w\W\s]*)(\"|')/", $opener, $attributes);
//                  preg_match_all("/([_\-A-Za-z0-9]*)((=\"|='))([_\-A-Za-z0-9]*)(\"|')/", $opener, $atts);
//                  $result = preg_match_all("!([_\-A-Za-z0-9]*)(=\"|=')([\#\s\:\.\?\&\=\%\+\,\@\_\-A-Za-z0-9]*)(\"|')!is", $matches[1][0], $attributes);
                    if(preg_match_all("!([_\-A-Za-z0-9]*)(=\")([^\"]*)(\")!is", $attribute_string, $attributes) > 0)
                    {
                        foreach($attributes[0] as $key=>$row)
                        {
                            $tag['attributes'][$attributes[1][$key]] = $attributes[3][$key];
                        }
                        if(isset($tag['attributes']['template']) === true)
                        {                                             
                            $template = $this->_options['template_directory'].$tag['name'].DIRECTORY_SEPARATOR.$tag['attributes']['template'].'.html';
                            if(is_file($template) === false)
                            {                                 
//                                $tag['attributes']['template'] = false;
                                $tag['attributes']['_template'] = $template;
                            }
                            else
                            {
                                $tag['attributes']['template'] = $template;
                            }
                        }
                    }
                } 
                $tag['attributes'] = (object) $tag['attributes'];
                return $tag;
            }
        }
766521
private function setName($name)
    {
        $name       = trim(strip_tags($name));
        $this->name = str_replace([' '], '-', $name);

        return $this;
    }
454986
private function tag_has_name(string $tag){
    return in_array('name', array_values(
      \is_array($this->tags[$tag]) ?
        $this->tags[$tag] :
        $this->tags[$this->tags[$tag]]
    ));
  }
534592
public function getTag($tagName)
    {
        foreach ($this->tags as $tag) {
            if ($tag['name'] === $tagName) {
                return $tag;
            }
        }

        throw new \InvalidArgumentException(sprintf(
            'Unknown tag "%s"', $tagName
        ));
    }
291578
public static function removeTagName(\DOMDocument $domdocument, $tagname)
    {
        $nodeLista = $domdocument->getElementsByTagName($tagname);
        if ($nodeLista->length > 0) {
            $node = $nodeLista->item(0);
            XmlUtil::removeNode($node);
            return true;
        } else {
            return false;
        }
    }
614134
public function add_related_tags($tagnames) {
        $context = context_system::instance();
        $tagobjects = static::create_if_missing($this->tagcollid, $tagnames);

        $currenttags = static::get_item_tags('core', 'tag', $this->id);

        foreach ($tagobjects as $name => $tag) {
            foreach ($currenttags as $currenttag) {
                if ($currenttag->name === $name) {
                    continue 2;
                }
            }
            $this->add_instance('core', 'tag', $tag->id, $context, 0);
            $tag->add_instance('core', 'tag', $this->id, $context, 0);
            $currenttags[] = $tag;
        }
    }
886008
function( tagName, inputString ) {
		let ret = inputString;

		if ( ret.indexOf( '<' + tagName ) === -1 ) {
			ret = `<${tagName}>${ret}`;
		}

		if ( ret.indexOf( '</' + tagName + '>' ) === -1 ) {
			ret = `${ret}</${tagName}>`;
		}

		return ret;
	}
1236951
private function subtag_check ($tagName)
  {
    $propName = lcfirst ($tagName);
    if ($this->current instanceof Metadata) {
      switch ($this->current->type) {
        // All descendants of a metadata property are always metadata.
        case type::metadata:
          return true;
      }
      // Descendants of a content property are children, not properties.
      return false;
    }
    // If the current component defines an property with the same name as the tag being checked, and if that property
    // supports begin specified as a tag, the tag is a subtag.
    return $this->current->supportsProperties () && $this->current->props->defines ($propName, true);
  }
362956
public function remove($type, $tagName = null)
	{
		if (preg_match('(^default(?:Child|Descendant)Rule)', $type))
		{
			throw new InvalidArgumentException('Cannot remove ' . $type);
		}

		if (isset($tagName))
		{
			$tagName = TagName::normalize($tagName);

			if (isset($this->items[$type]))
			{
				// Compute the difference between current list and our one tag name
				$this->items[$type] = array_diff(
					$this->items[$type],
					[$tagName]
				);

				if (empty($this->items[$type]))
				{
					// If the list is now empty, keep it neat and unset it
					unset($this->items[$type]);
				}
				else
				{
					// If the list still have names, keep it neat and rearrange keys
					$this->items[$type] = array_values($this->items[$type]);
				}
			}
		}
		else
		{
			unset($this->items[$type]);
		}
	}