@param string $token
@param string $output

@return string
340348
private function removeExtraTokens($token, $output)
    {
        [$prefix, $suffix] = explode('%s', $token);

        $prefix = preg_quote($prefix, '/');
        $suffix = preg_quote($suffix, '/');

        $output = preg_replace('/' . $prefix . '(?:context)\..+?' . $suffix . '/', '', $output);

        return $output;
    }
100349
public function generateFromToken($token) {
        if (!$token instanceof HTMLPurifier_Token) {
            trigger_error('Cannot generate HTML from non-HTMLPurifier_Token object', E_USER_WARNING);
            return '';

        } elseif ($token instanceof HTMLPurifier_Token_Start) {
            $attr = $this->generateAttributes($token->attr, $token->name);
            return '<' . $token->name . ($attr ? ' ' : '') . $attr . '>';

        } elseif ($token instanceof HTMLPurifier_Token_End) {
            return '</' . $token->name . '>';

        } elseif ($token instanceof HTMLPurifier_Token_Empty) {
            $attr = $this->generateAttributes($token->attr, $token->name);
             return '<' . $token->name . ($attr ? ' ' : '') . $attr .
                ( $this->_xhtml ? ' /': '' ) // <br /> v. <br>
                . '>';

        } elseif ($token instanceof HTMLPurifier_Token_Text) {
            return $this->escape($token->data, ENT_NOQUOTES);

        } elseif ($token instanceof HTMLPurifier_Token_Comment) {
            return '<!--' . $token->data . '-->';
        } else {
            return '';

        }
    }
1209331
protected function cleanOutput($output)
    {
        $output = str_replace($this->extraOutput, null, $output);

        return strtr($output, [
            'stdin: is not a tty' => null,
        ]);
    }
113406
private function createImages($output) {
        $image = array();
        
        foreach ($output as $key => $singleLine) {
            if (preg_match('/\(format/', $singleLine)) {
                $imageInfo  = $singleLine;
                $startPos   = strpos($imageInfo, "(") + 1;
                $endPos     = strpos($imageInfo, ")");
                $dataStr   = substr($imageInfo, $startPos, $endPos - $startPos);

                $dataExplode    = explode(",", $dataStr);
                $contentFormat  = explode(":", $dataExplode[0]);
                $format         = $contentFormat[1];
                $contentFormat  = explode(":", $dataExplode[1]);
                $type         = $contentFormat[1];

                $imageValue = $output[$key + 2];

                $exploded = explode(" ", $singleLine);
                $imagePath = array_shift($exploded);

                $image[] = new ZxingImage($imagePath, $imageValue, $format, $type);

            } else if(preg_match('/No barcode found/', $singleLine)) {
                
                $exploded = explode(" ", $singleLine);
                $imagePath = array_shift($exploded);
                $image[] = new ZxingBarNotFound($imagePath, 101, "No barcode found");
            }
        }

        return $image;
    }
43752
public static function out(string $text, $out = STDOUT)
    {
        if (!isset($output)) {
            $output = function ($text) use ($out) {
                fwrite($out, $text);
            };
        }

        $text = str_replace("\n", PHP_EOL, $text);
        $text = Ansi::tagsToColors($text);
        fwrite($out, $text);
    }
359985
public function assertCommandResultWithOutput($result, PyStringNode $output) {
        $this->assertCommandResult($result);
        $this->assertCommandOutputMatches($output);
    }
668493
protected function generateAndAttachLinkHeaders ($output)
    {
        $settings = Http2ServerPush::$plugin->getSettings();

        $headers = $this->fetchLinkableNodes($output, $settings->includeImages)
                        ->flatten(1)
                        ->map(function ($url) {
                            return $this->buildLinkHeaderString($url);
                        })
                        ->filter()
                        ->take($settings->limit)
                        ->implode(',');

        if ( !empty(trim($headers)) ) {
            $this->addLinkHeader($headers);
        }

        return $output;
    }
890520
private function getStreamOutput(StreamOutput $output = null)
    {
        if ($output) {
            rewind($output->getStream());
            $this->consoleOutput[] = trim(stream_get_contents($output->getStream()));
            fclose($output->getStream());
        }

        return new StreamOutput(fopen('php://memory', 'w+', false), StreamOutput::VERBOSITY_VERBOSE);
    }
207200
private function getFilteredOutput($output, $command)
    {
        $output = str_replace(array("\r\n", "\r"), array("\n", ''), $output);

        $matches = array();
        if (preg_match($this->getOutputFilterRegex($command), $output, $matches) === 1) {
            $output = ltrim($matches[1]);
        }

        return $output;
    }
491660
protected function postrender($output)
    {
        // insert objects' contents
        foreach ($this->objects as $key => $val) {
            $output = str_replace($key, $val, $output, $count);
            if ($count) {
                $this->objects[$key] = null;
            }
        }

        // make sure all <form> tags have a valid request token
        $output = preg_replace_callback('/<form\s+([^>]+)>/Ui', array($this, 'alter_form_tag'), $output);

        return $output;
    }
527783
public function renderSetextContent(Token $token) {
        $level = $token->get('level', 1);
        $content = $token->get('content', '');

        $line = str_pad('', max(2, strlen($content)), $level === 1 ? '=' : '-');

        return "\n" . $content . "\n" . $line;
    }
1362600
private function prepareTitleOutput($output)
    {
        return htmlspecialchars(
            Str::limit(strip_tags($output), $this->getMax()), ENT_QUOTES, 'UTF-8', false
        );
    }
1145353
private function getConsoleDisplay(StreamOutput $output)
    {
        rewind($output->getStream());
        $errors = [
            'The following errors occured during setup:',
            trim(stream_get_contents($output->getStream())),
        ];
        fclose($output->getStream());

        return nl2br(implode("\n", $errors));
    }
993510
public function output ($output)
    {
        $request = Craft::$app->getRequest();

        if ( $request->isCpRequest || $request->isLivePreview || $request->getAcceptsJson() ) {
            return $output;
        }

        return $this->generateAndAttachLinkHeaders($output);
    }
484589
public function output($buffer) {
        if (!$buffer && !$this->__result) {
            return '';
        }

        $out = '';
        // Always include the output generated by the expression first
        if ($buffer) {
            $out .= Garp_Cli::lineOut($buffer, null, true, false);
        }

        // And follow-up with the populated result, if any
        if ($this->__result) {
            // Try to format as user-friendly as possible
            $isObjWithToArray = is_object($this->__result) &&
                method_exists($this->__result, 'toArray');
            $this->__result = $isObjWithToArray ? $this->__result->toArray() : $this->__result;
            $this->__result = var_export($this->__result, true);
            $out .= Garp_Cli::lineOut($this->__result, Garp_Cli::BLUE, true, false);
        }

        return $out;
    }
987228
public function renderAttrs($token)
    {
        if (!isset($token->attrs)) return '';

        $result = '';

        foreach ($token->attrs as &$a) {
            $result .= ' ' . htmlspecialchars($a[0]) . '="' . htmlspecialchars($a[1]) . '"';
        }

        return $result;
    }
60242
public function output($output) {
		return fwrite($this->output, Text::insert($output, $this->styles()));
	}