Short description for function.

Long description (if any) ...

@param array $html Parameter description (if any) ...

@return mixed Return description (if any) ...
502629
public function parse($html)
    {
        if (!is_array($html)) {
            if (file_exists($html)) {
                $html = file($html);
            } else {
                return "Error opening template file $html";
            }
        }
        $return = '';
        foreach ($html as $line) {
            $return .= preg_replace_callback('/\<dynamic\s+name\s*=\s*[\'"](\S+?)[\'"]\>/i', [&$this, 'replace'], $line);
        }

        return $return;
    }
811431
public function truncateHtml($html, $length, $ellipsis = '...')
    {
        return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
    }
650095
public function jQueryValidationEngine($html)
	{
		$validation = array();
		if($this->required===true)
		{
			$validation[] = 'required';
		}
		if(!empty($validation))
			$html = str_replace("\" class=\"", "\" class=\"validate[".implode(',', $validation)."] ", $html);
		return $html;
	}
845111
protected function getFooterScriptsFrag($html)
    {
        if (!($html = (string) $html)) {
            return []; // Nothing to do.
        }
        if (preg_match('/(?P<all>(?P<open_tag>\<\!\-\-\s*footer[\s_\-]+scripts\s*\-\-\>)(?P<contents>.*?)(?P<closing_tag>(?P=open_tag)))/uis', $html, $head_frag)) {
            return $this->removeNumericKeysDeep($head_frag);
        }
        return [];
    }
1133613
public function addAttributesToHtml($html)
    {
        $html = trim((string) $html);

        $attributes = array_merge($this->getRequiredAttributes(), $this->attributes());
        $attributesString = Html::attributes($attributes);

        return preg_replace('|<(.*?)>|', "<$1$attributesString>", $html, 1);
    }
889847
private function _html($content) {
        // compress?
        if($this->_config['compress']['html'])
            $content = Algorithms::html($content, $this->_config['config']['html']);

        // return content
        return $content;
    }
447225
protected function tidy( $html ) {

		// Make XHTML 1.1 strict using htmlLawed

		$html = \Pressbooks\Interactive\Content::init()->replaceInteractiveTags( $html );

		$config = [
			'valid_xhtml' => 1,
			'no_deprecated_attr' => 2,
			'unique_ids' => 'fixme-',
			'deny_attribute' => 'itemscope,itemtype,itemref,itemprop,data*,aria*',
			'hook' => '\Pressbooks\Sanitize\html5_to_xhtml11',
			'tidy' => -1,
			'comment' => 1,
		];

		$spec = '';
		$spec .= 'img=-longdesc,-srcset;';
		$spec .= 'table=-border;';

		// Reset on each htmLawed invocation
		unset( $GLOBALS['hl_Ids'] );
		if ( ! empty( $this->fixme ) ) {
			$GLOBALS['hl_Ids'] = $this->fixme;
		}

		return \Pressbooks\HtmLawed::filter( $html, $config, $spec );
	}
909447
public function getDescription()
    {
        $description = $this->getShortDescription();
        if ($this->hasLongDescription()) {
            $description .= "\n\n" . $this->getLongDescription();
        }
        return $description;
    }
33994
public static function Html($html): string
    {
        // Remove newlines, tabs, zero
        $html = str_replace(["\0", "\t", "\r"], '', $html);

        // Remove spaces
        while (strpos($html, '  ') !== false) {
            $html = str_replace('  ', ' ', $html);
        }

        // Remove spaces after new lines
        $html = str_replace("\n ", "\n", $html);

        // Can optimize only without textarea, because in have to keep formatting
        $textarea = strpos($html, '<textarea');
        if ($textarea !== false) {
            // Remove double newlines
            while (strpos($html, "\n\n") !== false) {
                $html = str_replace("\n\n", "\n", $html);
            }
        }

        $fl = substr($html, 0, strpos($html, "\n")); // First line
        if (stripos($fl, 'strict') === false && substr($fl, 0, 5) !== '<?xml') {
            $html = str_replace('/>', '>', $html);
            if ($textarea === false) {
                $html = preg_replace('/([a-zA-Z0-9]+="[^"]+") /', '\\1', $html);
            }
        }
        $html = str_replace([' />'], ['/>'], $html);

        if ($textarea === false) {
            $html = str_replace("\n", '', $html);
        }

        return $html;
    }
206104
public static function returnDump( $var, $html = true ) {
		$dump = null;
		ob_start();
		var_dump( $var );
		$dump = ob_get_contents();
		ob_end_clean();
		if ( $html ) {
			return '<pre>' . htmlspecialchars( $dump ) . '</pre>';
		}
		return $dump;
	}
1273117
public static function createLinks($html)
    {
        return preg_replace_callback(
            '!((?:https?\://|\b\www\.).*?)([.,;:]( |$|<)|[ <]|$)!',
            function ($m) {
                $url = $m[1];
                $html = $m[1];
                if (!preg_match('/^https?:/', $url)) {
                    $url = 'http://' . $url;
                }
                return sprintf('<a href="%s">%s</a>%s', $url, $html, $m[2]);
            },
            $html
        );
    }
244160
private function parseAttributes(string $html): string
    {
        $remainingHtml = \mb_substr($html, mb_strlen($this->name) + 1);
        while (\mb_strpos($remainingHtml, '>') !== false && preg_match("/^\s*[\/]?>/", $remainingHtml) === 0) {
            $remainingHtml = $this->parseAttribute($remainingHtml);
        }

        return $remainingHtml;
    }
463510
public function getLongDescription($language)
    {
        if (isset($this['longDescr' . ucfirst($language)])) {
            return $this['longDescr' . ucfirst($language)];
        }

        if (isset($this['longDescr'])) {
            return $this['longDescr'];
        }
    }
516550
public function getExampleHtml($html = null)
    {
        if ($html === null) {
            if ($this->getMarkup() === null) {
                return '';
            }
            $html = $this->getMarkup();
        }

        if ($this->isExtender()) {
            $html = str_replace('$modifierClass', '', $html);

            // Use a positive lookbehind and lookahead to ensure we don't
            // replace anything more than just the targeted class name
            // for example an element name that is the same as the extended
            // class name (e.g. button)
            $pattern = sprintf('/(?<="| )%s(?="| )/', $this->getExtendedClassName());
            $html = preg_replace(
                $pattern,
                $this->getClassName(),
                $html
            );
        }

        $html = str_replace('$modifierClass', $this->getClassName(), $html);

        return $html;
    }
46259
public function setHtml($html)
	{
		if (is_array($html)) {
			throw new InvalidArgumentException(sprintf('Textual content must be a scalar, %s given.', gettype($html)));
		}
		$this->removeChildren();
		$this->children[] = (string)$html;

		return $this;
	}
894834
public function render($html = null) {
		if ($this->_tagCached === null) {
			$tag = '<' . $this->_tag;
			
			// Classes
			if (! empty($this->_classes)) {
				$this->setAttr(
					self::ATTR_CLASS,
					implode(' ', $this->_classes)
				);
			}

			// Style
			if (! empty($this->_style)) {
				$style = [];
				
				foreach ($this->_style as $param => $value) {
					$style[] = $param . ':' . $value . ';';
				}
				
				$this->setAttr(
					self::ATTR_STYLE,
					implode(' ', $style)
				);
			}

			// Attrs
			if (! empty($this->_attrs)) {
				$attrs = [];
				
				foreach ($this->_attrs as $attr => $value) {
					$attrs[] = $attr . '="' . $value . '"';
				}

				$tag .= ' ' .  implode(' ', $attrs);
			}
			
			$tag .= $this->_closed ? ' />' : '>';
			
			$this->_tagCached = $tag;
		}
		
		if ($this->_closed) {
			return $this->_tagCached;
		}
			
		return $this->_tagCached . ($html === null ? $this->_html : $html) . '</' . $this->_tag . '>';
	}
469707
protected function getHtmlFromRealPage($html)
    {
        // set body tag to lower case
        $html = str_replace('<BODY', '<body', $html);
        $html = str_replace('</BODY', '</body', $html);

        // explode from the body tag. If no body tag => end
        $res = explode('<body', $html);

        // the html content is between body tag openning and closing
        $content = '<page'.$res[1];
        $content = explode('</body', $content);
        $content = $content[0].'</page>';

        // extract the link tags from the original html
        // and add them before the content
        preg_match_all('/<link ([^>]*)[\/]?>/isU', $html, $match);
        foreach ($match[1] as $src) {
            $content = '<link '.$src.'/>'.$content;
        }

        // extract the css style tags from the original html
        // and add them before the content
        preg_match_all('/<style[^>]*>(.*)<\/style[^>]*>/isU', $html, $match);
        foreach ($match[0] as $src) {
            $content = $src.$content;
        }

        return $content;
    }