Minify javascript prefixes on html event attributes.

@param \ArjanSchouten\HtmlMinifier\MinifyContext $context

@return \ArjanSchouten\HtmlMinifier\MinifyContext
169502
public function process(MinifyContext $context)
    {
        $contents = preg_replace_callback(
            '/'.
                Constants::$htmlEventNamePrefix.Constants::ATTRIBUTE_NAME_REGEX.'   # Match an on{attribute}
                \s*=\s*             # Match equals sign with optional whitespaces around it
                ["\']?              # Match an optional quote
                \s*javascript:      # Match the text "javascript:" which should be removed
            /xis',
            function ($match) {
                return str_replace('javascript:', '', $match[0]);
            }, $context->getContents());

        return $context->setContents($contents);
    }
512643
protected function _actionAdd($context)
    {
        $data = $context->data;
        $body = $data->body;

        return $this->setItem($this->parent->addComment($body))->getItem();
    }
406173
private function expoundContext(&$context)
    {
        foreach ($context as $key => &$value) {
            if (is_array($value) || is_object($value)) {
                $this->expoundContext($value);
            }
            $t    = &$context;
            $keys = explode('.', $key);
            if (count($keys) > 1) {
                foreach ($keys as $subKey) {
                    if (!isset($t[$subKey])) {
                        $t[$subKey] = [];
                    }
                    $t = &$t[$subKey];
                }
                $t = $value;
                unset($context[$key]);
            }
        }
    }
1048647
public function render($context)
    {
        $closure = $this->options['callable'];
        return $closure($context, $this->getCell()->getActualRow());
    }
704970
public function bind(Context $context)
    {
        if (! isset($context->__UBID)) {
            $context->__UBID = 0;
        }
        $context->__UBID ++;
        
        return spl_object_hash($context) . $context->__UBID;
    }
404130
private function buildXMLAttributesString(Context $context) {
		$result = '';
		$matches = null;
		$attributes = $this->attributes;

		$runtimeAttributes = $context->getRuntimeAttributes();

		foreach($runtimeAttributes as $attributeName=>$runtimeAttr) {
			$attributes[$attributeName] = $runtimeAttr;
		}

		foreach($attributes as $attribute=>$value) {

			if( ! $context->view->isFigPrefix($attribute)) {
                // a flag attribute is to be processed differently because
                // it isn't a key=value pair.

                if ($value instanceof Flag) {
                    // Flag attribute: there is no value. We print only the name of the flag.
                    $result .= " $attribute";
                } else {

				    // We're potentially in presence of:
                    // - a plain scalar
                    // - an AdHoc instance
                    // - an array of the above.
                    // - an inline conditional attribute: InlineCondAttr

                    if ($value instanceof InlineCondAttr) {
                        /** @var InlineCondAttr $inlineCondAttr */
                        $inlineCondAttr = $value;
                        if ($this->evaluate($context, $inlineCondAttr->cond)) {
                            $value = $this->evaluate($context, $inlineCondAttr->val);
                        }
                        else {
                            continue;
                        }
                    }

                    if (! is_array($value)) {
                        $value = [$value];
                    }
                    $combined = '';
                    foreach ($value as $part) {
                        if ($part instanceof AdHoc) {
                            $evaluatedValue = $this->evaluate($context, $part->string);

                            if($evaluatedValue instanceof ViewElement) {
                                $evaluatedValue = $evaluatedValue->render($context);
                            }
                            if(is_array($evaluatedValue)) {
                                if(empty($evaluatedValue)) {
                                    $evaluatedValue = '';
                                } else {
                                    $message = 'Adhoc {' . $part->string . '} of attribute ' . $attribute . ' in tag "' . $this->name . '" evaluated to array.';
                                    throw new TagRenderingException($this->getTagName(), $this->getLineNumber(), $message);
                                }
                            } else if (is_object($evaluatedValue)
                                && ($evaluatedValue instanceof \DOMNode)) {

                                // Treat the special case of DOMNode descendants,
                                // for which we can evalute the text contents
                                $evaluatedValue = $evaluatedValue->nodeValue;
                            }

                            //The outcome of the evaluatedValue, coming from DB or other, might contain non-standard HTML characters.
                            //We assume that the FIG library targets HTML rendering.
                            //Therefore, let's have the outcome comply with HTML.
                            if(is_object($evaluatedValue)) {
                                //TODO: Log some warning!
                                $evaluatedValue = '### Object of class: ' . get_class($evaluatedValue) . ' ###';
                            } else {
                                $evaluatedValue = htmlspecialchars($evaluatedValue);
                            }

                            $part = $evaluatedValue;
                        }

                        // Append to what we had already (and if $part was a string in the first place,
                        // we use its direct value;
                        $combined .= $part;


                    }
                    $value = $combined;

                    $result .= " $attribute=\"$value\"";
				}
            }

        }
		return $result;
	}
1314865
private function minifyHTML($html)
    {
        $search = array('/(?:(?:\/\*(?:[^*]|(?:\*+[^*\/]))*\*+\/)|(?:(?<!\:|\\\|\'|\")\/\/.*))/', '/\n/', '/\>[^\S ]+/s', '/[^\S ]+\</s', '/(\s)+/s', '/<!--.*?-->/');
        $replace = array(' ', ' ', '>', '<', '\\1', '');

        $squeezedHTML = preg_replace($search, $replace, $html);

        return $squeezedHTML;

    }
1187162
protected function before(Context $context)
    {
        // kernel before handler
        $context = parent::before($context);

        // add templater to context
        $context->templater = $this->templater;

        // prepare templater helpers and globals vars
        $this->templater->vars['ctx'] = $context;
        $this->templater->helpers['url'] = [$context, 'url'];
        $this->templater->helpers['call'] = [$context, 'forward'];

        return $context;
    }
599387
public function render(Context $context) {
	    $context->pushTag($this);
		//================================================================
		//fig:macro
		//There is no condition to a macro definition.
		//A tag bearing the fig:macro directive is not implied mute.
		//It can render as a regular outer tag. If needed, it must be explicitly muted.
		if(null !== $this->figMacro) {
		    $result = $this->fig_macro($context);
		} else {
            $result = $this->renderNoMacro($context);

            // Clear transient flags
            $this->transientFlags = [];
        }
        $context->popTag();
		return $result;
	}
116370
protected function render($context)
    {
        $this->runtime->pushContextArray($context);
        $result = $this->runtime->render($this->path . '/renderer');
        $this->runtime->popContext();
        return $result;
    }
669920
public function filter(Context $context)
    {
        $this->index++;
        if(empty($this->m_filters) || $this->index >= count($this->m_filters))
            return;
        $filter=$this->m_filters[$this->index];
        return $filter->filter($context,$this);
    }
672135
protected function processPrefix(\DOMElement $element, ContextInterface $context)
    {
        if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) {
            $prefixes = preg_split('/\s+/', $element->getAttribute('prefix'));
            while (count($prefixes)) {
                $prefix = rtrim(array_shift($prefixes), ':');
                $uri = array_shift($prefixes);
                $context = $context->registerVocabulary($prefix, $uri);
            }
        }

        return $context;
    }
75654
private function nestContext(&$context)
    {
        foreach ($context as $key => $value) {
            $dot = strpos($key, '.');
            if ($dot && $dot !== strlen($key) - 1) {
                $currentContext = &$context;
                foreach (explode('.', $key) as $k) {
                    if (!isset($currentContext[$k])) {
                        $currentContext[$k] = [];
                    }
                    $currentContext = &$currentContext[$k];
                }
                $currentContext = $value;
                unset($context[$key]);
            }
        }

        return $context;
    }
371286
public function apply( $context ) {
		if ( ! $context instanceof RContext ) {
			$context = new Context( $context );
		}

		return $this->evaluate( $context );
	}
180212
protected function getAttributeProvider($context)
    {

        $extendName = $this->getContextExtendName($context);

        if ($this->hasExtension($extendName)) {
            return $this->getExtension($extendName);
        }

        return function($file) {
            return [
                'href'  =>$file->url,
                'class'=>'inline',
                'onclick'=>"window.open($(this).attr('href'), 'imgViewer','width=600,height=400'); return false;"];
        };

    }
1188023
public function setContext($context)
    {
        if (!is_array($context) && !$context instanceof \ArrayObject && !$context instanceof \Iterator) {
            throw new EventException('Unexpected value type for context', EventException::INVALID_CONTEXT);
        }

        $context = Collection::cast($context);

        $this->context = $context;

        return $this;
    }
91823
public function fireEvents($context)
    {
        if (!isset($context['__env'])) {
            return $context;
        }

        /** @var \Illuminate\View\Factory $factory */
        $env  = $context['__env'];
        $viewName = $this->name ?: $this->getTemplateName();

        $view = new View(
            $env,
            $env->getEngineResolver()->resolve('twig'),
            $viewName,
            null,
            $context
        );
        $env->callCreator($view);
        $env->callComposer($view);
        return $view->getData();
    }