/* Part 3 TODO: actually parse formulae
181495
function ods_to_csf_formula(f/*:string*/)/*:string*/ {
	if(f.slice(0,3) == "of:") f = f.slice(3);
	/* 5.2 Basic Expressions */
	if(f.charCodeAt(0) == 61) {
		f = f.slice(1);
		if(f.charCodeAt(0) == 61) f = f.slice(1);
	}
	f = f.replace(/COM\.MICROSOFT\./g, "");
	/* Part 3 Section 5.8 References */
	f = f.replace(/\[((?:\.[A-Z]+[0-9]+)(?::\.[A-Z]+[0-9]+)?)\]/g, function($$, $1) { return $1.replace(/\./g,""); });
	/* TODO: something other than this */
	f = f.replace(/\[.(#[A-Z]*[?!])\]/g, "$1");
	return f.replace(/[;~]/g,",").replace(/\|/g,";");
}
1345364
function(nodes, formula, root, reverse, ofType) {
      if (nodes.length == 0) return [];
      if (formula == 'even') formula = '2n+0';
      if (formula == 'odd')  formula = '2n+1';
      var h = Selector.handlers, results = [], indexed = [], m;
      h.mark(nodes);
      for (var i = 0, node; node = nodes[i]; i++) {
        if (!node.parentNode._counted) {
          h.index(node.parentNode, reverse, ofType);
          indexed.push(node.parentNode);
        }
      }
      if (formula.match(/^\d+$/)) { // just a number
        formula = Number(formula);
        for (var i = 0, node; node = nodes[i]; i++)
          if (node.nodeIndex == formula) results.push(node);
      } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
        if (m[1] == "-") m[1] = -1;
        var a = m[1] ? Number(m[1]) : 1;
        var b = m[2] ? Number(m[2]) : 0;
        var indices = Selector.pseudos.getIndices(a, b, nodes.length);
        for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
          for (var j = 0; j < l; j++)
            if (node.nodeIndex == indices[j]) results.push(node);
        }
      }
      h.unmark(nodes);
      h.unmark(indexed);
      return results;
    }
1127113
function parse(text) {
  const compCount = U.countComponents(text);
  if (!compCount) {
    return; // undefined
  }

  const len = text.length,
    components = new Array(compCount);

  let multiplier = 1,
    pos = 0,
    nextComp = 0;

  //console.log(`parsing unit ${text}:`);
  while (pos < len) {
    let ch = text.charCodeAt(pos);

    if (ch === U.slash) {
      multiplier *= -1;
      pos++;
    } else if (ch === U.asterisk) {
      pos++;
    }

    let s = pos;
    for (; pos < len; pos++) {
      ch = text.charCodeAt(pos);

      if (!U.isLetter(ch)) {
        break;
      }
    }

    const name = text.substring(s, pos);
    const unitType = bySid[name];
    if (!unitType) {
      throw new Error(`Unknown unit type "${name}" in "${text}"`);
    }

    if (pos < len && text.charCodeAt(pos) === U.caret) {
      pos++;
    }

    s = pos;
    if (pos < len && text.charCodeAt(pos) === U.minus) {
      pos++;
    }

    while (pos < len && U.isDigit(text.charCodeAt(pos))) {
      pos++;
    }

    const degreeText = text.substring(s, pos);

    let degree;
    if (!degreeText.length) {
      degree = 1;
    } else {
      degree = Number.parseInt(degreeText);
      if (isNaN(degree)) {
        throw new Error(`Illegal degree "${degreeText}" in "${text}"`);
      }
    }

    degree *= multiplier;

    let ci = 0;
    for (; ci < nextComp; ci++) {
      const comp = components[ci];

      if (comp.unitType === unitType) {
        comp.degree += degree;
        break;
      }
    }

    if (ci >= nextComp) {
      components[nextComp++] = new UnitTypeDegree(unitType, degree);
    }

    //console.log(` + ${name} ==> ${degree}`);
  }

  components.length = nextComp;
  return parseComponents(components);
}
302889
function parseFont (str) {
	str = str.trim();
	var str_o = str;
	var idx = 0;

	var style = rFontStyle.exec(str);
	style = getValue(style);
	str = str.replace(style, '').trim();

	var variant = rFontVariant.exec(str);
	variant = getValue(variant);
	str = str.replace(variant, '').trim();

	var weight = rFontWeight.exec(str);
	weight = getValue(weight);
	str = str.replace(weight, '').trim();

	var size = rFontSize.exec(str);
	// console.log('size', size);
	size = getValue(size);
	str = str.replace(size, '').trim();

	var lineHeight = rFontLineHeight.exec(str);
	lineHeight = getValue(lineHeight);
	str = str.replace(lineHeight, '').trim();
	lineHeight = lineHeight.slice(1);

	var fontFamily = str.trim();

	return {
		style: style,
		variant: variant,
		weight: weight,
		size: size,
		lineHeight: lineHeight,
		fontFamily: fontFamily,
		string: str_o
	};
}
447358
function parse_ArrayParsedFormula(blob, length, opts) {
	var target = blob.l + length, len = opts.biff == 2 ? 1 : 2;
	var rgcb, cce = blob.read_shift(len); // length of rgce
	if(cce == 0xFFFF) return [[],parsenoop(blob, length-2)];
	var rgce = parse_Rgce(blob, cce, opts);
	if(length !== cce + len) rgcb = parse_RgbExtra(blob, length - cce - len, rgce, opts);
	blob.l = target;
	return [rgce, rgcb];
}
969099
function parse(string) {
    var result = {},
        lines = string.split(/\r\n|\r|\n/),
        count = lines.length,
        pieces,
        key,
        value,
        meta,
        namespace;

    for (var i = 0; i < count; i++) {
        if (lines[i] === '') {
            continue;
        }
        if (lines[i].toUpperCase() === PREFIX || lines[i].toUpperCase() === POSTFIX) {
            continue;
        }
        var data = lines[i];

        /**
         * Check that next line continues current
         * @param {number} i
         * @returns {boolean}
         */
        var isValueContinued = function (i) {
            return i + 1 < count && (lines[i + 1][0] === ' ' || lines[i + 1][0] === '\t');
        };
        // handle multiline properties (i.e. photo).
        // next line should start with space or tab character
        if (isValueContinued(i)) {
            while (isValueContinued(i)) {
                data += lines[i + 1].trim();
                i++;
            }
        }

        pieces = data.split(':');
        key = pieces.shift();
        value = pieces.join(':');
        namespace = false;
        meta = {};

        // meta fields in property
        if (key.match(/;/)) {
            key = key
                .replace(/\\;/g, 'ΩΩΩ')
                .replace(/\\,/, ',');
            var metaArr = key.split(';').map(function (item) {
                return item.replace(/ΩΩΩ/g, ';');
            });
            key = metaArr.shift();
            metaArr.forEach(function (item) {
                var arr = item.split('=');
                arr[0] = arr[0].toLowerCase();
                if (arr[0].length === 0) {
                    return;
                }
                if (meta[arr[0]]) {
                    meta[arr[0]].push(arr[1]);
                } else {
                    meta[arr[0]] = [arr[1]];
                }
            });
        }

        // values with \n
        value = value
            .replace(/\\n/g, '\n');

        value = tryToSplit(value);

        // Grouped properties
        if (key.match(/\./)) {
            var arr = key.split('.');
            key = arr[1];
            namespace = arr[0];
        }

        var newValue = {
            value: value
        };
        if (Object.keys(meta).length) {
            newValue.meta = meta;
        }
        if (namespace) {
            newValue.namespace = namespace;
        }

        if (key.indexOf('X-') !== 0) {
            key = key.toLowerCase();
        }

        if (typeof result[key] === 'undefined') {
            result[key] = [newValue];
        } else {
            result[key].push(newValue);
        }

    }

    return result;
}
846935
function _convertRange3d($token)
	{
//		$class = 0; // formulas like Sheet1!$A$1:$A$2 in list type data validation need this class (0x3B)

		// Split the ref at the ! symbol
		list($ext_ref, $range) = explode('!', $token);

		// Convert the external reference part (different for BIFF8)
		$ext_ref = $this->_getRefIndex($ext_ref);

		// Split the range into 2 cell refs
		list($cell1, $cell2) = explode(':', $range);

		// Convert the cell references
		if (preg_match("/^(\\$)?[A-Ia-i]?[A-Za-z](\\$)?(\d+)$/", $cell1)) {
			list($row1, $col1) = $this->_cellToPackedRowcol($cell1);
			list($row2, $col2) = $this->_cellToPackedRowcol($cell2);
		} else { // It's a rows range (like 26:27)
			 list($row1, $col1, $row2, $col2) = $this->_rangeToPackedRange($cell1.':'.$cell2);
		}

		// The ptg value depends on the class of the ptg.
//		if ($class == 0) {
			$ptgArea = pack("C", $this->ptg['ptgArea3d']);
//		} elseif ($class == 1) {
//			$ptgArea = pack("C", $this->ptg['ptgArea3dV']);
//		} elseif ($class == 2) {
//			$ptgArea = pack("C", $this->ptg['ptgArea3dA']);
//		} else {
//			throw new PHPExcel_Writer_Exception("Unknown class $class");
//		}

		return $ptgArea . $ext_ref . $row1 . $row2 . $col1. $col2;
	}
545607
public function parseFormula($formula) {
		//	Basic validation that this is indeed a formula
		//	We return an empty array if not
		$formula = trim($formula);
		if ((!isset($formula{0})) || ($formula{0} != '=')) return array();
		$formula = ltrim(substr($formula,1));
		if (!isset($formula{0})) return array();

		//	Parse the formula and return the token stack
		return $this->_parseFormula($formula);
	}
1349036
function parse(text) {
    const textLineByLine = text.split(LINEBREAKE_MARK);
    // it should be alternately Str and Break
    let startIndex = 0;
    const lastLineIndex = textLineByLine.length - 1;
    const isLasEmptytLine = (line, index) => {
        return index === lastLineIndex && line === "";
    };
    const isEmptyLine = (line, index) => {
        return index !== lastLineIndex && line === "";
    };
    const children = textLineByLine.reduce(function(result, currentLine, index) {
        const lineNumber = index + 1;
        if (isLasEmptytLine(currentLine, index)) {
            return result;
        }
        // \n
        if (isEmptyLine(currentLine, index)) {
            const emptyBreakNode = createBRNode(lineNumber, startIndex);
            startIndex += emptyBreakNode.raw.length;
            result.push(emptyBreakNode);
            return result;
        }

        // (Paragraph > Str) -> Br?
        const strNode = parseLine(currentLine, lineNumber, startIndex);
        const paragraph = createParagraph([strNode]);
        startIndex += paragraph.raw.length;
        result.push(paragraph);
        if (index !== lastLineIndex) {
            const breakNode = createEndedBRNode(paragraph);
            startIndex += breakNode.raw.length;
            result.push(breakNode);
        }
        return result;
    }, []);
    return {
        type: Syntax.Document,
        raw: text,
        range: [0, text.length],
        loc: {
            start: {
                line: 1,
                column: 0
            },
            end: {
                line: textLineByLine.length,
                column: textLineByLine[textLineByLine.length - 1].length
            }
        },
        children
    };
}
927592
function () {
        return {
            lineSeparator: '\n', // done
            maxLength: 120, // TODO
            wrapIfLong: false, // TODO
            indent: 4, // done
            useTabIndent: false, // done
            spaces: {
                around: {
                    unaryOperators: false, // TODO
                    binaryOperators: true, // done
                    ternaryOperators: true // done
                },
                before: {
                    functionDeclarationParentheses: false, // done function foo() {
                    functionExpressionParentheses: true, // done var foo = function () {
                    parentheses: true, // done if (), for (), while (), ...
                    leftBrace: true, // done function () {, if () {, do {, try { ...
                    keywords: true // done if {} else {}, do {} while (), try {} catch () {} finally
                },
                within: {
                    // function call, function declaration, if, for, while, switch, catch
                    parentheses: false // done
                },
                other: {
                    beforePropertyNameValueSeparator: false, // done {key: value} {key : value} {key:value}
                    afterPropertyNameValueSeparator: true // done
                }
            },
            bracesPlacement: { // 1. same line 2. next line
                functionDeclaration: 1, // TODO
                other: 1 // TODO
            },
            blankLines: {
                keepMaxBlankLines: 1, // done
                atEndOfFile: true // done
            },
            other: {
                keepArraySingleLine: false // TODO default formatted array multi line
            },
            fix: {
                prefixSpaceToLineComment: false, // done
                alterCommonBlockCommentToLineComment: false, // done
                singleVariableDeclarator: false, // done
                fixInvalidTypeof: false, // done
                removeEmptyStatement: false, // done
                autoSemicolon: false, // done
                singleQuotes: false, // done
                eqeqeq: false, // done
                invalidConstructor: false, // done
                addCurly: false, // done
                removeDebugger: false, // done
                noElseReturn: false
            }
        };
    }
184336
function parse()
    {
        $criteria        = $this->criteria;
        $expectAsLiteral = $this->expectAsLiteral;


        $TOKENS  = preg_quote(static::TOKENS);

        $expectAsLiteral = (empty($expectAsLiteral)) ? '/@+-.' : $expectAsLiteral;
        $LITERAL = preg_quote($expectAsLiteral).'A-Za-z0-9_';


        $currentPos = 0;
        $length     = strlen($criteria);
        $parts      = [];
        $levelParts = [&$parts];
        $level      = 0;

        while ($currentPos < $length)
        {
            preg_match("(\G(?P<_literal_>[$LITERAL]*)(?P<_token_>[$TOKENS]|$))"
                , $criteria
                , $matches
                , 0
                , $currentPos
            );

            if ( empty($matches) )
                break;

            if (! empty($matches['_literal_']) ) {
                $levelParts[$level][] = ['_literal_' => $matches['_literal_']];
                $currentPos += strlen($matches['_literal_']);
            }

            # Deal With Token:
            if ( !isset($matches['_token_']) || $matches['_token_'] == '' )
                continue;

            $currentPos += strlen($matches['_token_']);
            $Token = $matches['_token_'];

            ## Regular Expression Token
            #
            #
            if ($Token === '~') {
                // ^ match any character that is not in list
                $pmatch = preg_match("/~(?P<_delimiter_>[^~]+)~/"
                    , $criteria
                    , $matches
                    , 0
                    , 0
                );
                if (! $pmatch )
                    throw new \RuntimeException('Miss usage of ~ ~ token.');

                $val['_regex_'] = $matches['_delimiter_'];
                $levelParts[$level][] = $val;

                $currentPos += strlen($matches[0])+2/*~x~*/;
            }
            ##
            # Variable
            # /:hash_id~\w{24}~
            #
            elseif ($Token === ':') {
                // ^$TOKENS  match any character that is not in list
                $pmatch = preg_match("(\G(?P<_name_>[^$TOKENS]+)(?:~(?P<_delimiter_>[^~]+)~)?:?)"
                    , $criteria
                    , $matches
                    , 0
                    , $currentPos
                );

                if (! $pmatch && !(isset($matches['_name_']) && isset($matches['_delimiter_'])) )
                    throw new \RuntimeException(
                        'Found empty parameter name or delimiter on (%s).'
                        , $criteria
                    );

                $parameter = $matches['_name_'];
                $val       = ['_parameter_' => $parameter];
                if (isset($matches['_delimiter_']))
                    $val[$parameter] = $matches['_delimiter_'];

                $levelParts[$level][] = $val;
                $currentPos += strlen($matches[0]);
            }

            ## Literal Token
            #  localhost\:port
            #
            elseif ($Token === '\\') {
                // Consider next character as Literal
                $nextChar = $currentPos += 1;
                $levelParts[$level][]   = ['_literal_' => $criteria[$nextChar]];
            }

            ## Optional Part
            #  /<u/:username~[a-zA-Z0-9._]+~><-:userid~\w{24}~>
            #
            elseif ($Token === '<') {
                if (! isset($va) ) {
                    $va = [];
                    $n = 0;
                }

                $n++;
                $va[$n] = [];
                $levelParts[$level][] = ['_optional_' => &$va[$n]];
                $level++;
                $levelParts[$level] = &$va[$n];
            }
            ## Close Optional ##
            elseif ($Token === '>') {
                unset($levelParts[$level]);
                $level--;

                if ($level < 0)
                    throw new \RuntimeException('Found closing bracket without matching opening bracket');
            }

            else
                // Recognized unused token return immanently
                $levelParts[$level][]   = ['_token_' => $Token];

        } // end while

        if ($level > 0)
            throw new \RuntimeException('Found unbalanced brackets');


        return ParsedCriteria::of($parts);
    }
708516
function parse_XLSBCell(data)/*:any*/ {
	var col = data.read_shift(4);
	var iStyleRef = data.read_shift(2);
	iStyleRef += data.read_shift(1) <<16;
	data.l++; //var fPhShow = data.read_shift(1);
	return { c:col, iStyleRef: iStyleRef };
}
667321
function parse_RfX(data /*::, length*/)/*:Range*/ {
	var cell/*:Range*/ = ({s: {}, e: {}}/*:any*/);
	cell.s.r = data.read_shift(4);
	cell.e.r = data.read_shift(4);
	cell.s.c = data.read_shift(4);
	cell.e.c = data.read_shift(4);
	return cell;
}
619870
def process_equations(key, value, fmt, meta):
    """"""

    if key == 'Math' and len(value) == 3:

        # Process the equation
        eq = _process_equation(value, fmt)

        # Get the attributes and label
        attrs = eq['attrs']
        label = attrs[0]
        if eq['is_unreferenceable']:
            attrs[0] = ''  # The label isn't needed outside this function

        # Context-dependent output
        if eq['is_unnumbered']:  # Unnumbered is also unreferenceable
            return None
        elif fmt in ['latex', 'beamer']:
            return RawInline('tex',
                             r'\begin{equation}%s\end{equation}'%value[-1])
        elif fmt in ('html', 'html5') and LABEL_PATTERN.match(label):
            # Present equation and its number in a span
            text = str(references[label])
            outerspan = RawInline('html',
                                  '<span %s style="display: inline-block; '
                                  'position: relative; width: 100%%">'%(''\
                                  if eq['is_unreferenceable'] \
                                  else 'id="%s"'%label))
            innerspan = RawInline('html',
                                  '<span style="position: absolute; '
                                  'right: 0em; top: %s; line-height:0; '
                                  'text-align: right">' %
                                  ('0' if text.startswith('$') and
                                   text.endswith('$') else '50%',))
            num = Math({"t":"InlineMath"}, '(%s)' % text[1:-1]) \
              if text.startswith('$') and text.endswith('$') \
              else Str('(%s)' % text)
            endspans = RawInline('html', '</span></span>')
            return [outerspan, AttrMath(*value), innerspan, num, endspans]
        elif fmt == 'docx':
            # As per http://officeopenxml.com/WPhyperlink.php
            bookmarkstart = \
              RawInline('openxml',
                        '<w:bookmarkStart w:id="0" w:name="%s"/><w:r><w:t>'
                        %label)
            bookmarkend = \
              RawInline('openxml',
                        '</w:t></w:r><w:bookmarkEnd w:id="0"/>')
            return [bookmarkstart, AttrMath(*value), bookmarkend]

    return None
827754
function() {

      var a = this['re'];
      var b = this['im'];
      var ret = '';

      if (this['isNaN']()) {
        return 'NaN';
      }

      if (this['isZero']()) {
        return '0';
      }

      if (this['isInfinite']()) {
        return 'Infinity';
      }

      if (a !== 0) {
        ret += a;
      }

      if (b !== 0) {

        if (a !== 0) {
          ret += b < 0 ? ' - ' : ' + ';
        } else if (b < 0) {
          ret += '-';
        }

        b = Math.abs(b);

        if (1 !== b) {
          ret += b;
        }
        ret += 'i';
      }

      if (!ret)
        return '0';

      return ret;
    }
944243
function ods_to_csf_formula(f) {
	if(f.substr(0,3) == "of:") f = f.substr(3);
	/* 5.2 Basic Expressions */
	if(f.charCodeAt(0) == 61) {
		f = f.substr(1);
		if(f.charCodeAt(0) == 61) f = f.substr(1);
	}
	f = f.replace(/COM\.MICROSOFT\./g, "");
	/* Part 3 Section 5.8 References */
	f = f.replace(/\[((?:\.[A-Z]+[0-9]+)(?::\.[A-Z]+[0-9]+)?)\]/g, function($$, $1) { return $1.replace(/\./g,""); });
	/* TODO: something other than this */
	f = f.replace(/\[.(#[A-Z]*[?!])\]/g, "$1");
	return f.replace(/[;~]/g,",").replace(/\|/g,";");
}
527469
function parseForms()
	{
		preg_match_all('/<form.*>.+<\/form>/isU', $this->html_data, $forms);
		foreach ($forms[0] as $form) {
			$this->button_counter = 0;

			//form details
			preg_match('/<form.*?name=["\']?([\w\s-]*)["\']?[\s>]/is', $form, $form_name);
			if ($form_name) {
				$this->_return[$this->_counter]['form_data']['name'] = preg_replace('/["\'<>]/', '', $form_name[1]);
			}
			preg_match('/<form.*?action=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $form, $action);
			if ($action) {
				$this->_return[$this->_counter]['form_data']['action'] = preg_replace('/["\'<>]/', '', $action[1]);
			}
			preg_match('/<form.*?method=["\']?([\w\s]*)["\']?[\s>]/is', $form, $method);
			if ($method) {
				$this->_return[$this->_counter]['form_data']['method'] = preg_replace('/["\'<>]/', '', $method[1]);
			}
			preg_match('/<form.*?enctype=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $form, $enctype);
			if ($enctype) {
				$this->_return[$this->_counter]['form_data']['enctype'] = preg_replace('/["\'<>]/', '', $enctype[1]);
			}
			preg_match('/<form.*?id=["\']?([\w\s-]*)["\']?[\s>]/is', $form, $id);
			if ($id) {
				$this->_return[$this->_counter]['form_data']['id'] = preg_replace('/["\'<>]/', '', $id[1]);
			}

			// form elements: input type = hidden
			if (preg_match_all('/<input[^<>]+type=["\']hidden["\'][^<>]*>/isU', $form, $hiddens)) {
				foreach ($hiddens[0] as $hidden) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($hidden)] = array(
						'type'  =>  'hidden',
						'value'  =>  $this->_getValue($hidden)
					);
				}
			}

			// form elements: input type = text
			if (preg_match_all('/<input[^<>]+type=["\']text["\'][^<>]*>/isU', $form, $texts)) {
				foreach ($texts[0] as $text) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
						'type' => 'text',
						'value' => $this->_getValue($text),
						'id' => $this->_getId($text),
						'class' => $this->_getClass($text)
					);
				}
			}

			/**
			 * HJW 18-7-2014 Magento 1.9.01. uses email as type for user credential
			 * form elements: input type = email
			 */
			if (preg_match_all('/<input[^<>]+type=["\']email["\'][^<>]*>/isU', $form, $texts)) {
				foreach ($texts[0] as $text) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
						'type'  => 'email',
						'value'  =>  $this->_getValue($text),
						'id'  =>  $this->_getId($text),
						'class'  =>  $this->_getClass($text)
					);
				}
			}

            // form elements: input type = email
            if (preg_match_all('/<input[^<>]+type=["\']email["\'][^<>]*>/isU', $form, $texts)) {
                foreach ($texts[0] as $text) {
                    $this->_return[$this->_counter]['form_elements'][$this->_getName($text)] = array(
                        'type'  => 'email',
                        'value'  =>  $this->_getValue($text),
                        'id'  =>  $this->_getId($text),
                        'class'  =>  $this->_getClass($text)
                    );
                }
            }

			// form elements: input type = password
			if (preg_match_all('/<input[^<>]+type=["\']password["\'][^<>]*>/isU', $form, $passwords)) {
				foreach ($passwords[0] as $password) {
					$this->_return[$this->_counter]['form_elements'][$this->_getName($password)] = array(
						'type'  =>  'password',
						'value'  =>  $this->_getValue($password)
					);
				}
			}

			// form elements: textarea
			if (preg_match_all('/<textarea.*>.*<\/textarea>/isU', $form, $textareas)) {
				foreach ($textareas[0] as $textarea) {
					preg_match('/<textarea.*>(.*)<\/textarea>/isU', $textarea, $textarea_value);
					$this->_return[$this->_counter]['form_elements'][$this->_getName($textarea)] = array(
						'type'  =>  'textarea',
						'value'  =>  $textarea_value[1]
					);
				}
			}

			// form elements: input type = checkbox
			if (preg_match_all('/<input[^<>]+type=["\']checkbox["\'][^<>]*>/isU', $form, $checkboxes)) {
				foreach ($checkboxes[0] as $checkbox) {
					if (preg_match('/checked/is', $checkbox)) {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($checkbox)] = array(
							'type'  =>  'checkbox',
							'value'  =>  'on'
						);
					} else {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($checkbox)] = array(
							'type'  =>  'checkbox',
							'value'  =>  ''
						);
					}
				}
			}

			// form elements: input type = radio
			if (preg_match_all('/<input[^<>]+type=["\']radio["\'][^<>]*>/isU', $form, $radios)) {
				foreach ($radios[0] as $radio) {
					if (preg_match('/checked/i', $radio)) {
						$this->_return[$this->_counter]['form_elements'][$this->_getName($radio)] = array(
							'type'  =>  'radio',
							'value'  =>  $this->_getValue($radio)
						);
					}
				}
			}

			// form elements: input type = submit
			if (preg_match_all('/<input[^<>]+type=["\']submit["\'][^<>]*>/isU', $form, $submits)) {
				foreach ($submits[0] as $submit) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'submit',
						'name'  => $this->_getName($submit),
						'value'  => $this->_getValue($submit)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = button
			if (preg_match_all('/<input[^<>]+type=["\']button["\'][^<>]*>/isU', $form, $buttons)) {
				foreach ($buttons[0] as $button) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'button',
						'name'  => $this->_getName($button),
						'value'  => $this->_getValue($button)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = reset
			if (preg_match_all('/<input[^<>]+type=["\']reset["\'][^<>]*>/isU', $form, $resets)) {
				foreach ($resets[0] as $reset) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'reset',
						'name'  => $this->_getName($reset),
						'value'  => $this->_getValue($reset)
					);
					$this->button_counter++;
				}
			}

			// form elements: input type = image
			if (preg_match_all('/<input[^<>]+type=["\']image["\'][^<>]*>/isU', $form, $images)) {
				foreach ($images[0] as $image) {
					$this->_return[$this->_counter]['buttons'][$this->button_counter] = array(
						'type'  => 'image',
						'name'  => $this->_getName($image),
						'value'  => $this->_getValue($image)
					);
					$this->button_counter++;
				}
			}

			// input type=select entries
			// Here I have to go on step around to grep at first all select names and then
			// the content. Seems not to work in an other way
			if (preg_match_all('/<select.*>.+<\/select>/isU', $form, $selects)) {
				foreach ($selects[0] as $select) {
					if (preg_match_all('/<option.*>.+<\/option>/isU', $select, $all_options)) {
						$option_value = '';
						foreach ($all_options[0] as $option) {
							if (preg_match('/selected/i', $option)) {
								if (preg_match('/value=["\'](.*)["\']\s/isU', $option, $option_value)) {
									$option_value = $option_value[1];
									$found_selected = 1;
								} else {
									preg_match('/<option.*>(.*)<\/option>/isU', $option, $option_value);
									$option_value = $option_value[1];
									$found_selected = 1;
								}
							}
						}
						if (!isset($found_selected)) {
							if (preg_match('/value=["\'](.*)["\']/isU', $all_options[0][0], $option_value)) {
								$option_value = $option_value[1];
							} else {
								preg_match('/<option>(.*)<\/option>/isU', $all_options[0][0], $option_value);
								$option_value = $option_value[1];
							}
						} else {
							unset($found_selected);
						}
						$this->_return[$this->_counter]['form_elements'][$this->_getName($select)] = array(
							'type'  => 'select',
							'value'  => trim($option_value)
						);
					}
				}
			}

			# form elements: input type = --not defined--
			if ( preg_match_all('/<input[^<>]+name=["\'](.*)["\'][^<>]*>/isU', $form, $inputs)) {
				foreach ($inputs[0] as $input) {
					if ( !preg_match('/type=("([^"]*)"|\'([^\']*)\'|[^>\s]*)([^>]*)?>/is', $input) ) {
						if ( !isset($this->_return[$this->_counter]['form_elements'][$this->_getName($input)]) ) {
							$this->_return[$this->_counter]['form_elements'][$this->_getName($input)] =
								array(
									'type'  => 'text',
									'value'  =>  $this->_getValue($input),
									'id'  =>  $this->_getId($input),
									'class'  =>  $this->_getClass($input)
								);

						}
					}
				}
			}

			// Update the form counter if we have more then 1 form in the HTML table
			$this->_counter++;
		}

		return $this->_return;
	}