Class it_html:

/**
 * INTERNAL: Create html tag from name and args array (the arguments of the parent function)
 */
function _tag($name, $args)
{
    list($data, $attr) = it_parse_args($args);

    $newline = isset($this->hasnonewline[$name]) ? "" : "\n";

    # Ultra XML PrettyPrinter 3000 [\] by SCA
    if ($this->p['prettyprint'] && $newline && (substr($data, -1, 1) == "\n") && (strpos($data, '<textarea') === false && strpos($data, '<pre') === false) && ($data != strip_tags($data)))
        $data = str_replace("\n", "\n  ", "\n" . trim($data)) . "\n";

    # debugging aid: add backtrace
    if (($levels = intval($this->p['srclines'])) && !it::match('^(head|meta|title|script|style|link)', $name))
        $attr = array('title' => it_debug::backtrace(array('levels' => max(3, $levels), 'skipfiles' => "_html\\.class"))) + $attr;

    $charset = $GLOBALS['it_html']->p['charset'];
    $result .= "<$name";

    # add attributes. If $value === true, use key only (<td nowrap> instead of <td nowrap=""> for old html, <td nowrap="nowrap"> for xhtml style)
    foreach($attr as $key => $value)
    {
        if (($value === null) || ($value === false))    # null or false: omit whole tag
            ;
        else if (isset($value) && $value !== true)    # normal case: value
        {
            if (preg_match('/[<>&"\x00-\x08\x0a-\x0c\x0e-\x1f\x80-\x9f\n\t\r]/', $value)) # WARNING: copy/pasted from Q()
                $result .= " $key=\"" . str_replace(["\n", "\t", "\r"], ["&#10;", "&#9;", "&#13;"], htmlspecialchars(self::_cleanup($value, $charset), ENT_COMPAT, $charset)) . '"';
            else
                $result .= " $key=\"$value\"";
        }
        else                        # true: tag without value
            $result .= ($this->p['htmltype'][0] != 'x') ? " $key" : " $key=\"$key\"";
    }

    # close tag according to html dialect
    if ($this->p['htmltype'] == 'xml')    # plain xml
        $result .= isset($data) ? ">$data</$name>$newline" : " />$newline";
    else if ($this->p['htmltype'][0] == 'x')    # xhtml: only voidtags can be shortened
        $result .= isset($data) || !self::$voidtags[$name] ? ">$data</$name>$newline" : " />$newline";
    else
        $result .= isset($data) || !self::$voidtags[$name] ? ">$data</$name>$newline" : ">$newline";

    if ($GLOBALS['debug_utf8check'] && $charset == "utf-8")
        $result = it::any2utf8($result, "error in $name()");

    return $result;
}