Parses Outlines recursive.
@access		protected
@return		void
339578
protected function parseOutlines( $node, &$array )
	{
		$outlines = $node->getChildren();
		foreach( $outlines as $outline )
		{
			$data	= array();
			foreach( $outline->getAttributes() as $key => $value )
				$data[$key]	= $value;
			if( $outline->hasChildren() )
				$this->parseOutlines( $outline, $data['outlines'] );
			else
				$data['outlines']	= array();
			$array[]	= $data;
		}
	}
654787
protected function parseFractions()
	{
		if (strpos($this->text, '/') === false)
		{
			return;
		}

		$map = [
			'1/4'  => "\xC2\xBC",
			'1/2'  => "\xC2\xBD",
			'3/4'  => "\xC2\xBE",
			'1/7'  => "\xE2\x85\x90",
			'1/9'  => "\xE2\x85\x91",
			'1/10' => "\xE2\x85\x92",
			'1/3'  => "\xE2\x85\x93",
			'2/3'  => "\xE2\x85\x94",
			'1/5'  => "\xE2\x85\x95",
			'2/5'  => "\xE2\x85\x96",
			'3/5'  => "\xE2\x85\x97",
			'4/5'  => "\xE2\x85\x98",
			'1/6'  => "\xE2\x85\x99",
			'5/6'  => "\xE2\x85\x9A",
			'1/8'  => "\xE2\x85\x9B",
			'3/8'  => "\xE2\x85\x9C",
			'5/8'  => "\xE2\x85\x9D",
			'7/8'  => "\xE2\x85\x9E",
			'0/3'  => "\xE2\x86\x89"
		];

		$regexp = '/\\b(?:0\\/3|1\\/(?:[2-9]|10)|2\\/[35]|3\\/[458]|4\\/5|5\\/[68]|7\\/8)\\b/S';
		preg_match_all($regexp, $this->text, $matches, PREG_OFFSET_CAPTURE);
		foreach ($matches[0] as $m)
		{
			$this->addTag($m[1], strlen($m[0]), $map[$m[0]]);
		}
	}
1333232
public function lineBreak()
    {
        echo $this->color->__invoke(str_repeat('─', $this->terminal->getWidth()))->yellow();
    }
797079
public function parse(){

		$docBlockList = $this->sanitize($this->block);

		foreach($docBlockList as $line){

			if(!empty($line)){

				if(empty($case))
					$case = "command";
				
				if(!empty($case) && in_array(strtolower($line), array(

					"usage:", 
					"arguments:", 
					"options:"

				))){

					$case = trim(strtolower($line),":");
					continue;
				}

				switch($case){

					case "command":

						list($cmdName, $cmdDescr) = explode(" ", $line, 2);

						$blockList["command"] = array(

							"alias"=>$cmdName, 
							"descr"=>$cmdDescr
						);

					break;
					case "usage":

						$parts = explode(" ", $line);
						$command = array_shift($parts);

						while($part = array_shift($parts)){

							if(preg_match("/^\[[-\w]+$/", $part)){

								$part = str_replace(array("["), "", $part);
								array_shift($parts);
								$blockList["usage"][$part] = array(

									"required"=>false, 
									"input"=>true
								);
							}							
							elseif(preg_match("/^\[[-\w]+\]$/", $part)){

								$part = str_replace(array("[","]"), "", $part);
								$blockList["usage"][$part] = array(

									"required"=>false, 
									"input"=>false
								);
							}							
							elseif(preg_match("/^(-|--)\w+$/", $part)){

								array_shift($parts);
								$blockList["usage"][$part] = array(

									"required"=>true, 
									"input"=>true
								);
							}							
							elseif(preg_match("/^<\w+>$/", $part)){

								$part = str_replace(array("<",">"), "", $part);
								$blockList["usage"][$part] = array(

									"required"=>true
								);
							}							
							elseif(preg_match("/^\[<\w+>\]$/", $part)){

								$part = str_replace(array("[","]","<",">"), "", $part);
								$blockList["usage"][$part] = array(

									"required"=>false
								);
							}
						}

					break;
					case "arguments":

						list($argument, $descr) = explode(" ", $line, 2);

						$blockList["arguments"][$argument]["descr"] = $descr;
						$blockList["arguments"][$argument]["optional"] = (strpos($line, "optional") !== false);

					break;
					case "options":

						$parts = explode(" ", $line, 3);

						$hasAlias=false;
						if(count($parts) == 3){

							$hasAlias = preg_match("/^-\w$/", next($parts));
							if($hasAlias)
								list($option, $alias, $descr) = $parts;

							if(!$hasAlias)
								list($option, $input, $descr) = $parts;
						}
							
						if(count($parts) == 2)
							list($option, $input) = $parts;

						$details["descr"] = @$descr;

						if($hasAlias){

							$details["alias"] = $alias;
							$blockList["aliases"][$alias] = $option;
						}

						$blockList["options"][$option] = $details;

					break;	
				}
			}
		}

		return $blockList;
	}
486220
public function traverse()
    {
        // If the recursive flag is passed, traverse recursively.
        if ($this->recursive) {
            $objects = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($this->path), \RecursiveIteratorIterator::SELF_FIRST
            );
            foreach ($objects as $fileInfo) {
                if (($fileInfo->getFilename() != '.') && ($fileInfo->getFilename() != '..')) {
                    $this->objects[] = $fileInfo;
                    // If absolute path flag was passed, store the absolute path.
                    if ($this->absolute) {
                        $f = null;
                        if (!$this->filesOnly) {
                            $f = ($fileInfo->isDir()) ? (realpath($fileInfo->getPathname())) : realpath($fileInfo->getPathname());
                        } else if (!$fileInfo->isDir()) {
                            $f = realpath($fileInfo->getPathname());
                        }
                        if (($f !== false) && (null !== $f)) {
                            $this->files[] = $f;
                        }
                    // If relative path flag was passed, store the relative path.
                    } else if ($this->relative) {
                        $f = null;
                        if (!$this->filesOnly) {
                            $f = ($fileInfo->isDir()) ? (realpath($fileInfo->getPathname())) : realpath($fileInfo->getPathname());
                        } else if (!$fileInfo->isDir()) {
                            $f = realpath($fileInfo->getPathname());
                        }
                        if (($f !== false) && (null !== $f)) {
                            $this->files[] = substr($f, (strlen(realpath($this->path)) + 1));
                        }
                    // Else, store only the directory or file name.
                    } else {
                        if (!$this->filesOnly) {
                            $this->files[] = ($fileInfo->isDir()) ? ($fileInfo->getFilename()) : $fileInfo->getFilename();
                        } else if (!$fileInfo->isDir()) {
                            $this->files[] = $fileInfo->getFilename();
                        }
                    }
                }
            }
            // Else, only traverse the single directory that was passed.
        } else {
            foreach (new \DirectoryIterator($this->path) as $fileInfo) {
                if(!$fileInfo->isDot()) {
                    $this->objects[] = $fileInfo;
                    // If absolute path flag was passed, store the absolute path.
                    if ($this->absolute) {
                        $f = null;
                        if (!$this->filesOnly) {
                            $f = ($fileInfo->isDir()) ?
                                ($this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . DIRECTORY_SEPARATOR) :
                                ($this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename());
                        } else if (!$fileInfo->isDir()) {
                            $f = $this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
                        }
                        if (($f !== false) && (null !== $f)) {
                            $this->files[] = $f;
                        }
                    // If relative path flag was passed, store the relative path.
                    } else if ($this->relative) {
                        $f = null;
                        if (!$this->filesOnly) {
                            $f = ($fileInfo->isDir()) ?
                                ($this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename() . DIRECTORY_SEPARATOR) :
                                ($this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename());
                        } else if (!$fileInfo->isDir()) {
                            $f = $this->path . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
                        }
                        if (($f !== false) && (null !== $f)) {
                            $this->files[] = substr($f, (strlen(realpath($this->path)) + 1));
                        }
                    // Else, store only the directory or file name.
                    } else {
                        if (!$this->filesOnly) {
                            $this->files[] = ($fileInfo->isDir()) ? ($fileInfo->getFilename()) : $fileInfo->getFilename();
                        } else if (!$fileInfo->isDir()) {
                            $this->files[] = $fileInfo->getFilename();
                        }
                    }
                }
            }
        }
    }
115525
private function parsing() : void
    {
        $lines = explode("\n", $this->raw);

        foreach ($lines as $line) {
            // check "at" mark
            if (false === strpos($line, '@')) {
                continue;
            }

            // check inline annotation
            if ($anp = strpos($line, '//')) {
                $line = substr($line, 0, $anp);
            }

            // trim blanks
            $line = trim(ltrim($line, ' *'));

            // analyze expr
            if (false === $fws = strpos($line, ' ')) {
                // @some-key
                $key = substr($line, 1);
                $val = true;
            } else {
                // @some-key some-val
                $key = substr($line, 1, $fws - 1);
                $val = trim(substr($line, $fws));
            }

            $this->lines[] = [$key, $val];

            $this->declares[$key][] = $val;
        }
    }
1189764
protected function parse()
	{
		$inside = false;
		$doc_open	= false;
		$func_data	= array();

		$f = new FS_File_Reader( $this->fileName );
		$lines = $f->readArray();
		array_pop( $lines );
		array_shift( $lines ); 
		foreach( $lines as $line )
		{
			$line = trim( $line );
			$line = str_replace( array( "*", "\t\t", "\t\t" ), array( "#", "\t", "\t" ), $line );
			if( $inside )
			{
				if( !$doc_open )
				{
					if( ereg( $this->patterns['doc_start'], $line ) )
						$doc_open = true;
					else if( ereg( $this->patterns["method"], $line ) )
					{
						$parts = explode( "function", $line );
						$method = substr( $parts[1], 0, strpos($parts[1], "(" ) );
						$method = str_replace( "&", "", $method );
						$method = trim( $method );
						$this->methods[$method] = $func_data;
						$func_data = array();
					}
				}
				if( $doc_open )
				{
					$found_pattern = false;
					if( ereg( $this->patterns["doc_data"], $line ) )
					{
						foreach( $this->methodProperties as $prop => $pattern )
						{
							if( ereg( $this->patterns[$pattern], $line ) )
							{
								$found_pattern = true;
								$func_data[$prop] = $this->getValueOfDocLine( $line, $pattern );
							}
						}
						if( ereg( $this->patterns["d_param"], $line ) )
						{
							$parts = explode( $this->patterns["d_param"], $line );
							$parts = explode( "\t", trim($parts[1] ) );
							$func_data["param"][$parts[1]]['type'] = $parts[0];
							if( isset( $parts[2] ) )
								$func_data["param"][$parts[1]]['desc'] = $parts[2];
						}
						else if( !$found_pattern && !ereg( $this->patterns['doc_end'], $line ) )
						{
							$desc = ereg_replace( $this->patterns["doc_data"], "", $line );
							$desc = trim( $desc );
							if( $desc )
								$func_data["desc"][] = $desc;
						}
					}
					else	if( ereg( $this->patterns["d_var"], $line ) )
					{
						$parts = explode( $this->patterns["d_var"], $line );
						$parts = preg_split( "@\t+@", trim($parts[1] ) );
						$this->vars[$parts[1]]['type'] = $parts[0];
						$access = ( substr($parts[1], 0, 1) == "_" ) ? "private" : "public";
							$this->vars[$parts[1]]['access'] = $access;
						$this->vars[$parts[1]]['desc'][] = str_replace( array( "#", "/" ), "", $parts[2] );
					}
					if( ereg( $this->patterns['doc_end'], $line ) )
						$doc_open = false;
				}
			}
			else
			{
				if( eregi( $this->patterns["import"], $line ) )
				{
					$import = str_replace( array( "import", " ", "(", ")", ";", "'", '"' ), "", $line );
					$parts = explode( ".", $import );
					$this->imports[$parts[count( $parts )-1]] = implode( "/", $parts );
				}
				else if( eregi( $this->patterns["class"], $line ) )
				{
					$line	= preg_replace( "@".$this->patterns["class"]."@i", "", $line );
					$parts = explode( " extends ", $line );
					$class = explode( " implements ", $parts[0] );
					$class = $class[0];
					
//					$class = str_replace( array( "class", " " ), "", $class );
					$this->classData["class"] = $class;
					if( isset( $parts[1] ) )
						$this->classData["extends"] = $parts[1];
					$inside = true;
				}
				else if( !$doc_open )
				{
					if( ereg( $this->patterns['doc_start'], $line ) )
						$doc_open = true;
				}
				else if( $doc_open )
				{
					if( ereg( $this->patterns['doc_end'], $line ) )
						$doc_open = false;
					else
					{
						if( ereg( $this->patterns["doc_data"], $line ) )
						{
							$found_pattern = false;
							foreach( $this->classProperties as $prop => $pattern )
							{
								if( ereg( $this->patterns[$pattern], $line ) )
								{
									$found_pattern = true;
									$this->classData[$prop][] = $this->getValueOfDocLine( $line, $pattern );
								}
							}
							if( !$found_pattern && !ereg( $this->patterns['doc_end'], $line ) )
							{
								if( ereg( $this->patterns['d_uses'], $line ) )
								{
									$parts = explode( $this->patterns["d_uses"], $line );
									$uses = trim( $parts[1] );
									if( !in_array ( $uses, $this->classData["uses"] ) )
										$this->classData["uses"][] = $uses; 
								}
								else if( ereg( $this->patterns['d_todo'], $line ) )
								{
									$parts = explode( $this->patterns["d_todo"], $line );
									$todo = trim( $parts[1] );
									if( !in_array( $todo, $this->classData["todo"] ) )
										$this->classData["todo"][] = $todo; 
								}
								else
								{
									$desc = ereg_replace( $this->patterns["doc_data"], "", $line );
									$desc = trim( $desc );
									if( $desc && !in_array( $desc, $this->classData["desc"] ) )
										$this->classData["desc"][] = $desc;
								}
							}
						}
					}	
				}
			}
		}
		foreach( $this->classProperties as $prop => $pattern )
			if( isset( $this->classData[$prop] ) && is_array( $this->classData[$prop] ) )
				$this->classData[$prop]	= array_unique( $this->classData[$prop] );
	}
43685
public function parse()
    {

        // parse the directories from the servlet managers configuration
        foreach ($this->getDirectories() as $directory) {
            // parse the directories for annotated servlets
            $this->parseDirectory(DirectoryKeys::realpath($directory));
        }
    }
96621
function o_outlines( $id, $action, $options = '' )
    {
        if ( $action != 'new' )
        {
            $o =& $this->objects[$id];
        }
        switch ( $action )
        {
        case 'new':
            $this->objects[$id] = array( 't' => 'outlines', 'info' => array( 'outlines' => array() ) );
            $this->o_catalog( $this->catalogId, 'outlines', $id );
            break;
        case 'outline':
            $o['info']['outlines'][] = $options;
            break;
        case 'out':
            if ( count( $o['info']['outlines'] ) )
            {
                $res = "\n" . $id . " 0 obj\n<< /Type /Outlines /Kids [";
                foreach ( $o['info']['outlines'] as $k => $v )
                {
                    $res .= $v . " 0 R ";
                }
                $res .= "] /Count " . count( $o['info']['outlines'] ) . " >>\nendobj";
            }
            else
            {
                $res = "\n" . $id . " 0 obj\n<< /Type /Outlines /Count 0 >>\nendobj";
            }
            return $res;
            break;
        }
    }
497526
def initialize_outlineexplorer(self):
        """"""
        for index in range(self.get_stack_count()):
            if index != self.get_stack_index():
                self._refresh_outlineexplorer(index=index)
1049748
protected function parse()
    {
        //reset object
        $descriptionDone = false;
        $this->fullDescriptionDone = false;

        //split lines
        $lines = explode("\n", $this->comment);

        //check lines for description or tags
        foreach ($lines as $line) {
            $pos = strpos($line, '* @');
            if (trim($line) == '/**' || trim($line) == '*/') { //skip the start and end line
            } elseif (!($pos === false)) { //comment
                $this->parseTagLine(substr($line, $pos + 3));
                $descriptionDone = true;
            } elseif (!$descriptionDone) {
                $this->parseDescription($line);
            }
        }
        //if full description is empty, put small description in full description
        if (trim(str_replace(array("\n", "\r"), array('', ''), $this->obj->fullDescription)) == '') {
            $this->obj->fullDescription = $this->obj->smallDescription;
        }
    }
1240576
public function parse()
    {
        if (preg_match_all($this->pattern, $this->originalString, $matches, PREG_SET_ORDER)) {
            $this->parsed = [];
            foreach ($matches as $match) {
                $code = explode(';', static::$colorMaps[$match['color']]);
                $parsed = [];
                if ($match['prefix']) {
                    $parsed = array_merge($parsed, $this->parseLine($match['prefix']));
                }
                $parsed = array_merge($parsed, $this->parseLine($match['str'], $code[1]));
                if ($match['suffix']) {
                    $parsed = array_merge($parsed, $this->parseLine($match['suffix']));
                }
                /*
                $this->parsed = array_merge(
                    $this->parsed,
                    // $this->parseLine($match['prefix']),
                    $this->parseLine($match['str'], $code[1])
                    // $this->parseLine($match['suffix'])
                );
                */
               $this->parsed = array_merge($this->parsed, $parsed);
            }
        } else {
            $this->parsed = $this->parseLine($this->originalString, null);
        }

        return $this;
    }
1328241
public function parse(): bool
    {
        if ($this->valid === true) {
            /**
             * Before processing through the deltas, generate new deltas by splliting
             * on all new lines, will make it much simpler to work out which
             * delta belong to headings, lists etc.
             */
            $this->quill_json = $this->splitInsertsByNewline($this->quill_json['ops']);

            foreach ($this->quill_json as $quill) {

                if ($quill['insert'] !== null) {
                    if (
                        array_key_exists('attributes', $quill) === true &&
                        is_array($quill['attributes']) === true
                    ) {
                        if (count($quill['attributes']) === 1) {
                            foreach ($quill['attributes'] as $attribute => $value) {
                                switch ($attribute) {
                                    case Options::ATTRIBUTE_BOLD:
                                        $this->attributeBold($quill);
                                        break;

                                    case Options::ATTRIBUTE_COLOR:
                                        $this->attributeColor($quill);
                                        break;

                                    case Options::ATTRIBUTE_HEADER:
                                        $this->attributeHeader($quill);
                                        break;

                                    case Options::ATTRIBUTE_ITALIC:
                                        $this->attributeItalic($quill);
                                        break;

                                    case Options::ATTRIBUTE_LINK:
                                        $this->attributeLink($quill);
                                        break;

                                    case Options::ATTRIBUTE_LIST:
                                        $this->attributeList($quill);
                                        break;

                                    case Options::ATTRIBUTE_SCRIPT:
                                        $this->attributeScript($quill);
                                        break;

                                    case Options::ATTRIBUTE_STRIKE:
                                        $this->attributeStrike($quill);
                                        break;

                                    case Options::ATTRIBUTE_UNDERLINE:
                                        $this->attributeUnderline($quill);
                                        break;

                                    default:
                                        $this->insert($quill);
                                        break;
                                }
                            }
                        } else {
                            $this->compoundInsert($quill);
                        }
                    } else {
                        if (is_string($quill['insert']) === true) {
                            $this->insert($quill);
                        } else {
                            if (is_array($quill['insert']) === true) {
                                if (array_key_exists('image', $quill['insert']) === true) {
                                    $this->image($quill);
                                } else if (array_key_exists('video', $quill['insert']) === true) {
                                    $this->video($quill);
                                }
                            }
                        }
                    }
                }
            }
            return true;
        } else {
            return false;
        }
    }
725705
private function fillStyleAttributesWithMergedStyles()
    {
        foreach ($this->styleAttributesForNodes as $nodePath => $styleAttributesForNode) {
            $node = $this->visitedNodes[$nodePath];
            $currentStyleAttributes = $this->parseCssDeclarationsBlock($node->getAttribute('style'));
            $node->setAttribute(
                'style',
                $this->generateStyleStringFromDeclarationsArrays(
                    $currentStyleAttributes,
                    $styleAttributesForNode
                )
            );
        }
    }
556144
private function _runParse( $path = NULL )
    {
        $startLevels  = $this->_getRealLevel( $this->_rootPath );
        $endLevels    = $startLevels + $this->levels;
        $currentLevel = 0;

        if ( NULL !== $path )
        {
            $this->_dirs[ ] = $path;
        }

        do
        {
            $dir          = array_shift( $this->_dirs );
            $currentLevel = $this->_getRealLevel( $dir );

            if ( $currentLevel < $endLevels )
            {
                $this->_parse( $dir );
            }
        } while ( count( $this->_dirs ) > 0 );
    }
27762
public function recursiveTidy($children)
    {

        foreach ($children as $page) {
            $write = false;

            // This is so something (events for example) can be purged.

            if ($this->purge && is_a($page, $this->purge, true)) {
                $page->delete();
                $this->purged++;
                continue;
            }

            // The most common issue is that the site ID doesn't match.

            if ($page->SiteID != $this->siteID) {

                // Update it to match.

                $page->SiteID = $this->siteID;
                $write        = true;
            }

            // The next issue is that duplicated URL segments have numbers appended (`URL-segment-2` for example).

            if (preg_match('%-[0-9]$%', $page->URLSegment)) {

                // When a page title ends with a number, the URL should match this.

                $last = substr($page->Title, -1);
                if (is_numeric($last)) {

                    // Determine whether this actually needs fixing.

                    if ($last !== substr($page->URLSegment, -1)) {

                        // Update it to match.

                        $page->URLSegment = $page->Title;
                        $write            = true;
                    }
                }

                // The number appended shouldn't exist.
                else {

                    // Determine whether this is considered unique (otherwise it can't be updated).

                    $to = substr($page->URLSegment, 0, -2);
                    if (!SiteTree::get()->filter(array(
                            'ParentID' => $page->ParentID,
                            'URLSegment' => $to
                        ))->exists()) {

                        // This isn't unique, so update it.

                        $page->URLSegment = $to;
                        $write            = true;
                    }
                }
            }

            // Determine whether this page needs a write.

            if ($write) {
                $page->write();
                $this->count++;
            }

            // Where necessary, continue further down.

            $this->recursiveTidy($page->AllChildren());
        }
    }
257045
protected function computePreservesNewLines()
	{
		foreach ($this->branches as $branch)
		{
			$style = '';
			foreach ($branch as $element)
			{
				$style .= $this->getStyle($element, true);
			}

			if (preg_match('(.*white-space\\s*:\\s*(no|pre))is', $style, $m) && strtolower($m[1]) === 'pre')
			{
				$this->preservesNewLines = true;

				return;
			}
		}
		$this->preservesNewLines = false;
	}