Handles a BBCode opening tag
@param string $tag
@param array $attrs
@return bool
518223
private function tag_open($tag, $attrs)
	{
		if($this->current_tag instanceof Node_Container_Tag)
		{
			$closing_tags = $this->bbcodes[$this->current_tag->tag()]->closing_tags();

			if(in_array($tag, $closing_tags))
				$this->tag_close($this->current_tag->tag());
		}

		if($this->current_tag instanceof Node_Container_Tag)
		{
			$accepted_children = $this->bbcodes[$this->current_tag->tag()]->accepted_children();

			if(!empty($accepted_children) && !in_array($tag, $accepted_children))
				return false;

			if($this->throw_errors && !$this->bbcodes[$tag]->is_inline()
				&& $this->bbcodes[$this->current_tag->tag()]->is_inline())
				throw new Exception_InvalidNesting("Block level tag [{$tag}] was opened within an inline tag [{$this->current_tag->tag()}]");
		}

		$node = new Node_Container_Tag($tag, $attrs);
		$this->current_tag->add_child($node);

		if(!$this->bbcodes[$tag]->is_self_closing())
			$this->current_tag = $node;

		return true;
	}
508587
protected function varStartHandler(array $attrs): void
    {
        if (preg_match('/^I18N::number\((.+)\)$/', $attrs['var'], $match)) {
            $this->text .= I18N::number((int) $match[1]);
        } elseif (preg_match('/^I18N::translate\(\'(.+)\'\)$/', $attrs['var'], $match)) {
            $this->text .= I18N::translate($match[1]);
        } elseif (preg_match('/^I18N::translateContext\(\'(.+)\', *\'(.+)\'\)$/', $attrs['var'], $match)) {
            $this->text .= I18N::translateContext($match[1], $match[2]);
        } else {
            $this->text .= $attrs['var'];
        }
    }
38696
public function onReplaceInsertTags(string $tag)
    {
        $elements = \explode('::', $tag);
        $key = \strtolower(\array_shift($elements));

        if ('tag' === $key) {
            return $this->replaceInsertTag($elements);
        }

        return false;
    }
636272
def handle_starttag(self, tag, attrs):
        """"""
        if (tag in self.newline_before_elements):
            self.text += '\n'
        if (tag in self.stroke_before_elements and not
                self.text.endswith(self.stroke_text)):
            # Put a stroke in front of every relevant element, if there is some
            # content between it and its predecessor
            self.text += self.stroke_text
        if tag == 'a':
            # If it's a link, append it to the link list
            for attr in attrs:
                if attr[0] == 'href':
                    self.links.append((len(self.links) + 1, attr[1]))
127062
protected function handleTagOpenForObject( $parser, $tag, $attributes )
	{
		$count		= count( $this->last ) - 1;
		$parentNode	=& $this->last[$count];
		$childNode	= new XML_DOM_Node(
			$tag,
			"",
			$attributes
		);
		$parentNode->addChild( $childNode );
		$this->last[]	=& $childNode;
	}
1082071
public static function createElement($tag = '', $attributes1 = [], $attributes2 = [])
    {
        $tag_object = parent::createElement($tag);
        $tag_object->setTag($tag);
        $attributes = $attributes1;
        if (!is_array($attributes1) && strlen($attributes1) > 0) {
            $tag_object->text($attributes1);
            $attributes = $attributes2;
        }
        if (is_array($attributes)) {
            foreach ($attributes as $name => $value) {
                if (method_exists($tag_object, $name)) {
                    if (!is_array($value)) {
                        $value = [$value];
                    }
                    call_user_func_array([$tag_object, $name], $value);
                }
            }
        }

        $tag_object->configDefaults($tag);

        return $tag_object;
    }
569346
function _tag_open( &$parser, $tag, $attributes ) {
		$this->currentElement = strtoupper( $tag );

		switch( $this->currentElement ) {
			case 'ROW':
				$this->row = count( $this->data );
				$this->data[$this->row] = array();
				break;
			case 'F':
				$this->addField($attributes);
			default:
				// print_r( array( $tag, $attributes ) );
		}
	}
848150
public static String enclose(Tag tag, String text, AttributeValue... attrs) {

        return open(tag, attrs) + text + close(tag);
    }
482843
private function openTagHandler($xmlParser, $tagName, $attributes) {
		if($this->firstOpening) {
			$this->firstOpening = false;

			//Position the namespace:
			$matches = null;
			foreach($attributes as $attrName => $attrValue) {
				if(preg_match('/figdice/', $attrValue) &&
					 preg_match('/xmlns:(.+)/', $attrName, $matches)) {
					$this->figNamespace = $matches[1] . ':';
					break;
				}
			}

            // Remove the fig xmlns directive from the list of attributes of the opening root tag
            // (as it should not be rendered)
            unset($attributes['xmlns:' . substr($this->figNamespace, 0, strlen($this->figNamespace) - 1)]);

			// Consume optional fig:trans directive
            if (isset($attributes[$this->figNamespace.'trans'])) {
                $this->defaultTransSource = $attributes[$this->figNamespace.'trans'];
                // Remove the attribute from the list of attributes of the opening root tag
                unset($attributes[$this->figNamespace.'trans']);
            }
        }

		$lineNumber = xml_get_current_line_number($xmlParser);


		//
		// Detect special tags
        //
		if($tagName == $this->figNamespace . TagFigAttr::TAGNAME) {
			$newElement = new TagFigAttr($tagName, $lineNumber);
		} else if ($tagName == $this->figNamespace . TagFigCdata::TAGNAME) {
            $newElement = new TagFigCdata($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigDictionary::TAGNAME) {
            $newElement = new TagFigDictionary($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigFeed::TAGNAME) {
		    $newElement = new TagFigFeed($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigInclude::TAGNAME) {
		    $newElement = new TagFigInclude($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigMount::TAGNAME) {
		    $newElement = new TagFigMount($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigParam::TAGNAME) {
		    $newElement = new TagFigParam($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigTrans::TAGNAME) {
		    $newElement = new TagFigTrans($tagName, $lineNumber);
        } else if ($tagName == $this->figNamespace . TagFigVal::TAGNAME) {
		    $newElement = new TagFigVal($tagName, $lineNumber);
        } else {
			$newElement = new ViewElementTag($tagName, $lineNumber, $this->previousCData);
		}

		$this->previousCData = null;

		$newElement->setAttributes($this->figNamespace, $attributes);


		if($this->rootNode) {
            /** @var ViewElementTag $parentElement */
			$parentElement = & $this->stack[count($this->stack)-1];
			$newElement->parent = &$parentElement;

			//Since the new element has a parent, then the parent is not autoclose.
			$newElement->parent->autoclose = false;

			$parentElement->appendChild($newElement);
		} else
		{
			//If there no root node yet, then this new element is actually
			//the root element for the view.
			$this->rootNode = &$newElement;
		}

		$this->stack[] = & $newElement;
	}
819089
public function getChild($tag, $attrs = [])
    {
        $ret = null;
        if ($this->children) {
            if (is_int($tag)) {
                if (isset($this->children[$tag])) {
                    return $this->children[$tag];
                } else {
                    return;
                }
            }
            foreach ($this->children as $child) {
                if (strcmp($child->tag, $tag) == 0) {
                    $found = true;
                    foreach ($attrs as $key => $value) {
                        if (strcmp($child->getAttribute($key), $value) != 0) {
                            $found = false;
                            break;
                        }
                    }
                    if ($found) {
                        return $child;
                    }
                }
                $ret = $child->getChild($tag, $attrs);
                if ($ret) {
                    return $ret;
                }
            }
        }
    }
799693
public static function attsToString(Tag &$Tag)
    {
        /*
         * Return empty string if tag does not have attributes.
         */
        if (empty($Tag->attributes)) {
            return '';
        }

        $r = ' ';
        foreach ($Tag->attributes as $key => $value) {
            /*
             * Validate the attribute name.
             */
            $tmp = $key;
            if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrNameValidation($key)) {
                self::debug(sprintf('Invalid attribute name "%s" was changed to "%s"', $tmp, $key), 2, 7);
            }

            /*
             * If we have an value we make sure critical letters are escaped and use the format :name=":value"
             */
            if (!empty($value)) {
                $tmp = $value;
                if (!$Tag->hasOption('dontValidateAttrs') && !self::ensureAttrValueValidation($value)) {
                    self::debug(sprintf('Dangerous attribute value "%s" was changed to "%s"', $tmp, $value), 2, 7);
                }
                $value = str_replace('"', '&quot;', $value);
                $r .= "$key=\"$value\" ";
            } elseif ($value !== false) {
                /*
                 * No value? Alright just take the name.
                 */
                $r .= $key.' ';
            }
        }

        /*
         * Remove the last space and return.
         */

        return rtrim($r, ' ');
    }
103183
public function createTag($tag, $attr = NULL, $content = NULL)
    {
        $temp = '<'.$tag;
        if($attr != NULL) {
            $attr = (array) $attr;
            foreach($attr as $key => $val) {
                if(is_numeric($key)) {
                    $val = strtolower(trim($val));
                    if(isset($this->attr[$tag][$val])) {
                        $args[$val] = $this->attr[$tag][$val];
                        //$args[] = $val.($this->attr[$tag][$val] == NULL ? '' : "=\"{$this->attr[$tag][$val]}\"");
                    }
                    else {
                        $args[$val] = NULL;
                    }
                }
                else {
                    if(!isset($args[$key])) {
                        $args[$key] = $val;
                    }
                }
                if(isset($this->attr[$tag][$key])) {
                    if(is_array($this->attr[$tag][$key])) {
                        foreach($this->attr[$tag][$key] as $k => $v) {
                            if(isset($v[$val]) && !isset($args[$val])) {
                                $args[$k] = $v[$val];
                            }
                        }
                    }
                    else {
                        if(!isset($args[$val])) {
                            $args[$key] = $this->attr[$tag][$key];
                        }
                    }
                }
            }
            unset($attr);
            foreach($args as $key => $val) {
                $attr[] = $key.($val == NULL ? '' : "=\"$val\"");
            }
            unset($args);
            $args = array_unique($attr);
            $args = implode(' ', $args);
        }
        $temp .= isset($args) ? ' '.$args.'>' : '>'; 
        if($content != NULL) {
            if(is_array($content)) {
                array_walk($content, function(&$val, $key) { $val = trim($val); } );//5.3
                $content = implode("\n",$content);
                $content = explode("\n", $content);
                $content = preg_replace('/^/', "\t", $content);
                #$content = preg_filter('/^/', "@", $content);
                $content = rtrim("\n".implode("\n", $content), "\n")."\n";
            }
            $temp .= $content;
        }
        if($this->tags[$tag] === true) {
            $temp .= '</'.$tag.'>';
        }
        return $temp;
    }
1264228
public static function renderFormBegin(Form $form, array $attrs, $withTags = TRUE)
	{
		$renderer = $form->getRenderer();
		if ($renderer instanceof IManualRenderer) {
			$renderer->beforeRender($form);
		}
		return parent::renderFormBegin($form, $attrs, $withTags);
	}
1034374
public static String open(Tag tag, AttributeValue... attrs) {

        StringBuffer sb = new StringBuffer();
        sb.append("<").append(tag.name());
        for (AttributeValue attr : attrs) {
            sb.append(" ").append(attr.toString());
        }
        sb.append(">");
        return sb.toString();
    }
805553
protected static function process_inserts ($tag, $in, $attributes) {
		$insert = $attributes['insert'];
		unset($attributes['insert']);
		$html = '';
		foreach (static::inserts_processing([$in, $attributes], $insert) as $d) {
			$html .= static::render_tag($tag, $d[0], $d[1]);
		}
		return $html;
	}
273282
public function buildInput($attrs)
    {
        if ($this->getBool('hr')) {
            $node = 'hr';

            $content = null;
        } else {
            $node = $this->getAttribute('tag', 'span');

            $content = $this->getAttribute('description');
        }

        return new HtmlElement($node, $content, $attrs);
    }
91316
public static function open($tag, array $options = [], $self = false)
    {
        $attributes = self::attributes($options);

        //add the opened tag to $opened array
        if (!$self || is_null($self)) {
            self::$opened[] = $tag;
            //
            return '<'.$tag.$attributes.'>';
        } else {
            return '<'.$tag.$attributes.' />';
        }
    }