@param array $arguments array of arguments from the content
@param string $caption text between the [] [/] brackets

@return String of parsed youtube movie.
179705
public static function YouTubeHandler($arguments, $caption = null)
    {
        // If there's no ID, just stop.
        if (empty($arguments['id'])) {
            return null;
        }
        /*		 * * SET DEFAULTS ** */
        $defaults = array(
            'YouTubeID' => $arguments['id'],
            'autoplay'  => false,
            'caption'   => $caption ? Convert::raw2xml($caption) : false,
            'width'     => 640,
            'height'    => 385,
        );

        //overide the defaults with the arguments supplied
        $customise = array_merge($defaults, $arguments);
        $template = new SSViewer('YouTube');

        return $template->process(new ArrayData($customise));
    }
1347180
protected function getTokens(array $arguments)
    {
        $tokens = array();
        foreach ($arguments as $argument) {
            $argumentTokens = preg_split('/([\s.,!])+/', $argument);
            $tokens = array_merge($tokens, $argumentTokens);
        }

        return array_values(array_filter($tokens));
    }
89016
public static function mergeArgumentElements( array $argumentElements )
    {
        $instance = self::instance();
        $argumentText = '';
        foreach ( $argumentElements as $element )
        {
            if ( is_int( $element ) )
            {
                $argumentText .= str_repeat( ' ', $element );
            }
            else if ( is_string( $element ) )
            {
                $argumentText .= $instance->escapeShellArgument( $element );
            }
        }
        return $argumentText;
    }
1249745
protected function parseArguments(array $arguments): array
	{
		$parsed = [];

		$argumentNumber = 0;

		foreach($arguments as $argument)
		{
			if(preg_match(static::NAMED_ARGUMENT_REGEX, $argument) === 1)
			{
				[$name, $value] = explode('=', substr($argument, 2), 2) + [null, null];

				$parsed[$name] = $value === null ? true : $value;
			}
			else
			{
				$parsed['arg' . $argumentNumber++] = $argument;
			}
		}

		return $parsed;
	}
660390
public function videoToHtml()
    {
        if (in_array($this->provider, $this->providers)) {
            $caption = '';
            if (!empty($this->caption)) {
                $caption = $this->parser->toHtml($this->caption);
            }

            // View
            return $this->view(
                'video.'.$this->provider,
                [
                    'remote' => $this->remoteId,
                    'caption' => $caption,
                ],
                $this->provider
            );
        }

        return '';
    }
1062544
public function parse($text, $replaceLinks = true)
    {
        $resources = [];

        // Find media
        $regex = '#[src|href]+="([^"]*file/resource/media/([^\'"]+))"#';

        preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
        if (count($matches) > 0) {
            foreach ($matches as $match) {
                $node = $this->resourceManager->getNode($match[2]);
                if ($node) {
                    $resources = $this->storeResource($resources, $node);

                    if ($replaceLinks) {
                        $text = $this->replaceLink($text, $match[1], '../files/file_'.$match[2]);
                    }
                }
            }
        }

        // Find videos (it's a particular case because the url is not same)
        // We also have the Resource id, not the Node one
        $regex = '#[src|href]+="([^"]*video-player/api/video/([^\'"]+)/stream)"#';

        preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
        if (count($matches) > 0) {
            foreach ($matches as $match) {
                // We have the ID of the Resource, not the Node
                $resource = $this->om->getRepository('ClarolineCoreBundle:Resource\File')->find($match[2]);
                if ($resource) {
                    $node = $resource->getResourceNode();
                    $resources = $this->storeResource($resources, $node);

                    if ($replaceLinks) {
                        $text = $this->replaceLink($text, $match[1], '../files/file_'.$node->getId());
                    }
                }
            }
        }

        // Find resources
        $regex = '#[src|href]+="([^"]*resource/open/([^/]+)/([^\'"]+))"#';

        preg_match_all($regex, $text, $matches, PREG_SET_ORDER);
        if (count($matches) > 0) {
            foreach ($matches as $match) {
                $node = $this->resourceManager->getNode($match[3]);
                if ($node) {
                    $resources = $this->storeResource($resources, $node);

                    if ($replaceLinks) {
                        $text = $this->replaceLink($text, $match[1], '../scos/resource_'.$match[3].'.html');
                    }
                }
            }
        }

        return [
            'text' => $text,
            'resources' => $resources,
        ];
    }
955660
public function open($vars = '', $caption = '')
    {
        if (!empty($caption)) {
            $caption = '<caption>'.$caption.'</caption>';
        }

        return "\n".$this->page->tag('table', $this->values($vars)).$caption;
    }
317638
private function parseArgs(array $args) : string
    {
        if (!is_array($args)) return false;
        $components = array();
        if (count($args) == 1 && is_string($args[0])) {
            $components['src'] = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 1 && is_array($args)) {
            $components = $args[0];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_array($args[1])) {
            $args[1]['src'] = $args[0];
            $components = $args[1];
            return $this->makeLink($components);
        } elseif (count($args) == 2 && is_string($args[0]) && is_string($args[1])) {
            return '<script type="'.$args[1].'">'."\n".$args[0]."\n</script>\n";
        }
        Core::i()->log->warning('Unable to interpret script. Not added.');
        return false;
    }
37415
private static function getArguments(array $arguments = [])
    {
        $args = [];

        foreach ($arguments as $argument) {
            $args[] = $argument instanceof self ? $argument->getMoney() : $argument;
        }

        return $args;
    }
936467
public static function constructStringFromArguments(array $arguments): string
    {
        $result = '';
        foreach ($arguments as $argument) {
            $result .= ' ' . $argument;
        }

        return $result;
    }
122600
private function parseArgs($args) {
        $command = $action = null;
        $params = [];
        foreach ($args as $argument) {
            if ('-' != $argument[0])
                if (null === $command)
                    $command = $argument;
                elseif (null === $action)
                    $action = $argument;
                else
                    $this->alert('Invalid argument ' . $argument . '!', ['command' => $command, 'action' => $action, 'serverArguments' => $_SERVER['argv'], 'processedArguments' => $args]);
            else {
                $argument = substr($argument, 1); // supports both  one - or two - ( - / -- )
                if ('-' == $argument[0])
                    $argument = substr($argument, 1);

                $argument = explode('=', $argument, 2);
                $params[$argument[0]] = isset($argument[1]) ? $argument[1] : true;
            }
        }
        return [
            'command' => $command,
            'action' => $action,
            'params' => $params
        ];
    }
9191
function(args, content, options){
			var lines = utils.parseLinesCells(content, false);
			var output = "<table>\n";
			if(args && args[0])	// args[0] === table caption
				output += "<caption>"+args[0]+"</caption>\n";
			lines.forEach(function(cells){
				if(!cells.length)
				{
					output += "<tr></tr>\n";
					return;
				}
				output += "<tr>\n";
				cells.forEach(function(cell){
					output += "<td>"+cell+"</td>";
				});
				output += "\n</tr>\n";
			})
			output  += "</table>\n";
			return output;
		}
967031
private function formatArguments($arguments)
    {
        return collect($arguments)->map(function ($argument) {
            return $argument instanceof Model ? FormatModel::given($argument) : $argument;
        })->toArray();
    }
1011677
private function escape(array $arguments)
    {
        $args = array();
        foreach ($arguments as $k => $v) {
            if (is_array($v)) {
                $args[$k] = $this->escape($v);
            } elseif (is_string($v)) {
                $args[$k] = str_replace('%', '%%', $v);
            } else {
                $args[$k] = $v;
            }
        }

        return $args;
    }
559209
protected function mapArguments(array $arguments)
    {
        $keys = isset($this->mappableArguments[$this->element()]) ? $this->mappableArguments[$this->element()] : [];

        return array_combine(array_slice($keys, 0, count($arguments)), $arguments);
    }
1061483
public function ClassifyText(\Google\Cloud\Language\V1\ClassifyTextRequest $argument,
      $metadata = [], $options = []) {
        return $this->_simpleRequest('/google.cloud.language.v1.LanguageService/ClassifyText',
        $argument,
        ['\Google\Cloud\Language\V1\ClassifyTextResponse', 'decode'],
        $metadata, $options);
    }
72177
protected function getCaptions($videoInfo, $detailed=false) {
		$index = 0;
		$captions = array();
		$captionTracks = explode(',', $videoInfo['caption_tracks']);

		foreach($captionTracks as $captionTrack) {
			$decodedTrack = $this->decodeString($captionTrack);

			$language = $index++;

			if (isset($decodedTrack['lc']))
				$language = $decodedTrack['lc'];

			if (isset($decodedTrack['v']) && $decodedTrack['v'][0] != '.')
				$language = $decodedTrack['v'];

			if ($detailed)
				$captions[$language] = $decodedTrack;
			else
				$captions[$language] = $decodedTrack['n'];
		}

		return $captions;
	}