function to capture regular content between tags
544111
private function get_content()
    {
        $input_char = '';
        $content = array();
        $space = false; //if a space is needed

        while (isset($this->input[$this->pos]) && $this->input[$this->pos] !== '<') {

            if ($this->pos >= $this->input_length) {
                return count($content) ? implode('', $content) : array('', 'TK_EOF');
            }

            if ($this->traverse_whitespace()) {
                if (count($content)) {
                    $space = true;
                }
                continue; //don't want to insert unnecessary space
            }

            $input_char = $this->input[$this->pos];
            $this->pos++;

            if ($space) {
                if ($this->line_char_count >= $this->options['wrap_line_length']) { //insert a line when the wrap_line_length is reached
                    $this->print_newline(false, $content);
                    $this->print_indentation($content);
                } else {
                    $this->line_char_count++;
                    $content[] = ' ';
                }
                $space = false;
            }
            $this->line_char_count++;
            $content[] = $input_char; //letter at-a-time (or string) inserted to an array
        }

        return count($content) ? implode('', $content) : '';
    }
323290
function parseSearchResults (html) {
  const $ = cheerio.load(html)
  return $('a')
    .filter(function (index, element) {
      const spans = $(element).find('span')
      return spans.length === 2 && spans.eq(0).text().trim() === 'English'
    })
    .map(function (index, element) {
      const title = $(element).find('span').eq(1).text().trim()
      const url = $(element).attr('href')
      return new SearchResult({
        title: title,
        url: url
      })
    })
    .get()
}
939392
function (content) {
            return content.split('\\').join("\\\\").split("\n").join("\\n").split('"').join('\\"').split("\t").join("\\t");
        }
707607
function(template) {

		var i = 0,
			count = template.length,
			result = [];

		for (; i < count; i++) {

			if (typeof(template[i]) == 'string') {

				if (!Lava.EMPTY_REGEX.test(template[i])) Lava.t("Text between tags is not allowed in this context. You may want to use a lava-style comment ({* ... *})");

			} else {

				result.push(template[i]);

			}

		}

		return result;

	}
1155094
function(text) {

            urls = [];
            titles = [];
            htmlBlock = [];

            text = text.replace(/~/g,"~T");
            text = text.replace(/\$/g,"~D");
            text = text.replace(/\r\n/g,"\n");
            text = text.replace(/\r/g,"\n");
            text = "\n\n" + text + "\n\n";
            text = detab(text);
            text = text.replace(/^[ \t]+$/mg,"");
            text = hashHTMLBlocks(text);
            text = stripLinkDefinitions(text);
            text = runBlockGamut(text);
            text = unescapeSpecialChars(text);
            text = text.replace(/~D/g,"$$");
            text = text.replace(/~T/g,"~");

            return text;
        }
109342
function recogniseContentType( data ) {
		if ( CKEDITOR.env.webkit ) {
			// Plain text or ( <div><br></div> and text inside <div> ).
			if ( !data.match( /^[^<]*$/g ) && !data.match( /^(<div><br( ?\/)?><\/div>|<div>[^<]*<\/div>)*$/gi ) )
				return 'html';
		} else if ( CKEDITOR.env.ie ) {
			// Text and <br> or ( text and <br> in <p> - paragraphs can be separated by new \r\n ).
			if ( !data.match( /^([^<]|<br( ?\/)?>)*$/gi ) && !data.match( /^(<p>([^<]|<br( ?\/)?>)*<\/p>|(\r\n))*$/gi ) )
				return 'html';
		} else if ( CKEDITOR.env.gecko ) {
			// Text or <br>.
			if ( !data.match( /^([^<]|<br( ?\/)?>)*$/gi ) )
				return 'html';
		} else
			return 'html';

		return 'htmlifiedtext';
	}
1255067
function tag(name, attrs, close, content) {
  var end = close ? '/>' : '>';
  var pairs = [];
  var tag;

  for (var key in attrs) {
    if (Object.prototype.hasOwnProperty.call(attrs, key)) {
      pairs.push(key + '="' + escape(attrs[key]) + '"');
    }
  }

  tag = '<' + name + (pairs.length ? ' ' + pairs.join(' ') : '') + end;
  if (content) {
    tag += content + '</' + name + end;
  }
  return tag;
}
23465
function filterTags(tags, content) {
  if (!tags) {
    return content;
  }
  const $ = cheerio.load(content, { xmlMode: false });
  const tagOperations = tags.map(tag => ({
    // Trim leading + or -, replace * with .*, add ^ and $
    tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`,
    // Whether it is makes tags visible or hides them
    isHidden: tag.startsWith('-'),
  }));
  $('[tags]').each((i, element) => {
    $(element).attr('hidden', true);
    $(element).attr('tags').split(' ').forEach((tag) => {
      tagOperations.forEach((tagOperation) => {
        if (!tag.match(tagOperation.tagExp)) {
          return;
        }
        if (tagOperation.isHidden) {
          $(element).attr('hidden', true);
        } else {
          $(element).removeAttr('hidden');
        }
      });
    });
  });
  $('[hidden]').remove();
  return $.html();
}
918650
function dummyMarkdown() {
    var codeBlock = /^```/;
    var quoteBlock = /^>/;
    var listBlock = /^\* /;

    var commentInline = '<!--.*-->';
    var codeInline = '`.+`';

    function split(content) {
        var pattern = new RegExp([commentInline, codeInline].join('|'), 'g');
        var result = null;
        var last = 0;
        var output = [];

        while ((result = pattern.exec(content)) !== null) {
            output.push({ transform: true, content: content.slice(last, result.index)});
            output.push({ transform: false, content: result[0]});
            last = pattern.lastIndex;
        }

        output.push({ transform: true, content: content.slice(last)});

        return output;
    }

    return function (input) {
        var output = [];
        var lines = input.split('\n');

        for (var l = 0; l < lines.length; l++) {
            var line = lines[l];
            var e;
            var content;

            if (codeBlock.test(line)) {
                e = l + 1;
                while (!codeBlock.test(lines[e])) {
                    e++;
                }

                output.push({ transform: false, content: lines.slice(l, e + 1).join('\n') + '\n\n' });
                l = e;
            } else if (quoteBlock.test(line)) {
                e = l + 1;
                while (quoteBlock.test(lines[e])) {
                    e++;
                }

                content = [line].concat(lines.slice(l + 1, e).map(function (nextLine) {
                    return nextLine.slice(2);
                })).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (listBlock.test(line)) {
                e = l + 1;
                while (lines[e] !== '') {
                    if (!listBlock.test(lines[e])) {
                        lines[e - 1] += ' ' + lines[e];
                        lines[e] = '';
                    }
                    e++;
                }

                content = lines.slice(l, e).filter(function (line) {
                    return line !== '';
                }).join('\n') + '\n';

                output = output.concat(split(content));
                l = e - 1;
            } else if (line !== '') {
                e = l + 1;
                while (lines[e] !== '') {
                    e++;
                }

                content = lines.slice(l, e).join(' ') + '\n\n';

                output = output.concat(split(content));
                l = e - 1;
            }
        }

        return output;
    };
}
677754
function createHtmlText(tokens) {
  var htmlText = '';

  tokens.forEach(function(t) {
    if (t.matched) {
      htmlText += '<strong class="' + SearchPad.RESULT_HIGHLIGHT_CLASS + '">' + t.matched + '</strong>';
    } else {
      htmlText += t.normal;
    }
  });

  return htmlText !== '' ? htmlText : null;
}
112547
def _soup_strings(soup):
  """"""
  paragraph_tags = set([
      "caption", "details", "h1", "h2", "h3", "h4", "h5", "h6", "li", "p", "td",
      "div", "span"
  ])

  skip_children = None
  for descendant in soup.descendants:
    # If we've treated a tag as a contiguous paragraph, don't re-emit the
    # children (see below).
    if skip_children is not None:
      try:
        in_skip = descendant in skip_children  # pylint: disable=unsupported-membership-test
      except RecursionError:  # pylint: disable=undefined-variable
        # Possible for this check to hit a nasty infinite recursion because of
        # BeautifulSoup __eq__ checks.
        in_skip = True
      if in_skip:
        continue
      else:
        skip_children = None

    # Treat some tags as contiguous paragraphs, regardless of other tags nested
    # inside (like <a> or <b>).
    if isinstance(descendant, bs4.Tag):
      if descendant.name in paragraph_tags:
        if descendant.find_all(paragraph_tags):
          # If there are nested paragraph tags, don't treat it as a single
          # contiguous tag.
          continue
        skip_children = list(descendant.descendants)
        text = " ".join(descendant.get_text(" ", strip=True).split())
        if text:
          yield text
        continue

    if (isinstance(descendant, bs4.Comment) or
        not isinstance(descendant, bs4.NavigableString)):
      continue

    text = " ".join(descendant.strip().split())
    if text:
      yield text
520823
function htmlToComponent(str, tags, opts) {
  var keys = objectKeys(tags);
  var props = opts.props || {};
  var preserveAttributes = opts.preserveAttributes || [];
  var tagAttributes = [];
  var reactTags={};
  var reactKeys=[];
  var key;
  for(var i = 0; i<keys.length; i++) {
    key = "AB"+Math.random().toString(36).substring(2);
    if(typeof tags[keys[i]] !== "function") {
      if(typeof tags[keys[i]].slice !== "function") continue;
      tagAttributes = tags[keys[i]].slice(0,-1);
      reactTags[key] = tags[keys[i]].slice(-1)[0];
    }
    else
      reactTags[key] = tags[keys[i]];

    reactKeys.push(key);

    str = str
      .replace(new RegExp("(<\/?)"+keys[i]+"(?:[^>\"']|\".*\"|'.*')*>", "ig"), function(match, start){
        // find/replace spell-save attributes within tag to restore capitals
        if(start !== "</")
          for(var a=0; a<tagAttributes.length; a++)
            match = replaceAttribute(match, tagAttributes[a], tagAttributes[a]);

        // replace key
        return match
          .replace(new RegExp(start+keys[i]+"(\\s|>)", "i"), start+key+"$1");
      });
  }

  // remove/disable html comments
  str = str.replace(/<!--|-->/g,"")

  // find/replace global spell-save attributes to restore capitals
  var attributes = preserveReactAttributes.concat(preserveAttributes);
  for(var i=0; i<attributes.length; i++) 
    str = replaceAttribute(str, attributes[i], attributes[i]);
 
  var jsx = htmlToJsx(str);

  // replace props variables {key} with corrected variables {props['key']}
  for(var key in props) {
    jsx = jsx
      .replace(new RegExp("(\{"+key+"\})","g"),"{props['"+key+"']}");
  }
  
  var component = ReactTransform(jsx).code;
  
  // replace component variables (ComponentName) with corrected variables (tags['ComponentName'])
  for(var i=0; i<reactKeys.length; i++) {
    component = component
      .replace(new RegExp(reactKeys[i],"g"), "reactTags['"+reactKeys[i]+"']"); 
  }

  return eval(component);
}
215173
def title_from_content(content):
    
    for end in (". ", "?", "!", "<br />", "\n", "</p>"):
        if end in content:
            content = content.split(end)[0] + end
            break
    return strip_tags(content)
194972
def get_content(pattern, string, tag='content'):
    
    output = []
    for match in re.finditer(pattern, string):
        output.append(match.group(tag))
    return output
858068
function grab(url, content) {
  // make sure hrefs is an array even if is singleton
  var hrefsAsArray = _.isArray(content.hrefs) ? content.hrefs : [content.hrefs]
  return {
    url: url,
    content: _.omit(content, 'hrefs'),
    hrefs: hrefsAsArray,
    child: {}
  }
}
713081
function matchToHolders(match, tag) {
  return object(match.map(function(val, index) {
    return [tag+":"+index, val];
  }));
}
282620
function getTags(rawHtml, reTag) {
    var result = [];
    var match, attributes;

    while (match = reTag.exec(rawHtml)) {
        attributes = parseAttributes(match[2] || '');

        result.push({name: match[1], attributes: attributes, raw: match[0]});
    }

    return result;
}