Convert a cleaned parsel.Selector to text.
    See html_text.extract_text docstring for description of the approach
    and options.
542643
def selector_to_text(sel, guess_punct_space=True, guess_layout=True):
    
    import parsel
    if isinstance(sel, parsel.SelectorList):
        # if selecting a specific xpath
        text = []
        for s in sel:
            extracted = etree_to_text(
                s.root,
                guess_punct_space=guess_punct_space,
                guess_layout=guess_layout)
            if extracted:
                text.append(extracted)
        return ' '.join(text)
    else:
        return etree_to_text(
            sel.root,
            guess_punct_space=guess_punct_space,
            guess_layout=guess_layout)
576010
function parse(selector) {
  var self = this;
  var remaining = self.inputText = selector;
  var currentQuery = self[0] = newQuery();
  self.length = 1;
  remaining = consumeWhitespace(remaining); // get rid of leading whitespace

  for (;;) {
    var exprInfo = consumeExpr(remaining);

    if (exprInfo.expr == null) {
      warn('The selector `' + selector + '`is invalid');
      return false;
    } else {
      var args = exprInfo.match.slice(1); // let the token populate the selector object in currentQuery

      var ret = exprInfo.expr.populate(self, currentQuery, args);

      if (ret === false) {
        return false; // exit if population failed
      } else if (ret != null) {
        currentQuery = ret; // change the current query to be filled if the expr specifies
      }
    }

    remaining = exprInfo.remaining; // we're done when there's nothing left to parse

    if (remaining.match(/^\s*$/)) {
      break;
    }
  }

  var lastQ = self[self.length - 1];

  if (self.currentSubject != null) {
    lastQ.subject = self.currentSubject;
  }

  lastQ.edgeCount = self.edgeCount;
  lastQ.compoundCount = self.compoundCount;

  for (var i = 0; i < self.length; i++) {
    var q = self[i]; // in future, this could potentially be allowed if there were operator precedence and detection of invalid combinations

    if (q.compoundCount > 0 && q.edgeCount > 0) {
      warn('The selector `' + selector + '` is invalid because it uses both a compound selector and an edge selector');
      return false;
    }

    if (q.edgeCount > 1) {
      warn('The selector `' + selector + '` is invalid because it uses multiple edge selectors');
      return false;
    } else if (q.edgeCount === 1) {
      warn('The selector `' + selector + '` is deprecated.  Edge selectors do not take effect on changes to source and target nodes after an edge is added, for performance reasons.  Use a class or data selector on edges instead, updating the class or data of an edge when your app detects a change in source or target nodes.');
    }
  }

  return true; // success
}
64209
function getText(element) {
    var text = "";

    var isRecentFirefox = (browserVersion.isFirefox && browserVersion.firefoxVersion >= "1.5");
    if (isRecentFirefox || browserVersion.isKonqueror || browserVersion.isSafari || browserVersion.isOpera) {
        text = getTextContent(element);
    } else if (element.textContent) {
        text = element.textContent;
    } else if (element.innerText) {
        text = element.innerText;
    }

    text = normalizeNewlines(text);
    text = normalizeSpaces(text);

    return text.trim();
}
1106888
function selectText(element)
			{
				if(element)
				{
					var element = element[0];
					
					if (document.body.createTextRange)
					{
						var range = document.body.createTextRange();
						range.moveToElementText(element);
						range.select();
					}
					else if (window.getSelection)
					{
						var selection = window.getSelection();  
						var range = document.createRange();
						
						if(element != "undefined" && element != null)
						{
							range.selectNodeContents(element);
							
							selection.removeAllRanges();
							selection.addRange(range);
							
							if($(element).is(":empty"))
							{
								$(element).append("&nbsp;");
									selectText($(element));
							}
						}
					}
				}
			}
1194740
def _get_element_text_or_none(document, selector):
    
    element = document.cssselect(selector)
    if element:
        return element[0].text
    return None
1217096
def parse(self, text, as_html=True):
        
        if not text:
            return text
        entity_text = self.get_text(text)

        if self.type == MessageEntityType.BOLD:
            if as_html:
                return markdown.hbold(entity_text)
            return markdown.bold(entity_text)
        elif self.type == MessageEntityType.ITALIC:
            if as_html:
                return markdown.hitalic(entity_text)
            return markdown.italic(entity_text)
        elif self.type == MessageEntityType.PRE:
            if as_html:
                return markdown.hpre(entity_text)
            return markdown.pre(entity_text)
        elif self.type == MessageEntityType.CODE:
            if as_html:
                return markdown.hcode(entity_text)
            return markdown.code(entity_text)
        elif self.type == MessageEntityType.URL:
            if as_html:
                return markdown.hlink(entity_text, entity_text)
            return markdown.link(entity_text, entity_text)
        elif self.type == MessageEntityType.TEXT_LINK:
            if as_html:
                return markdown.hlink(entity_text, self.url)
            return markdown.link(entity_text, self.url)
        elif self.type == MessageEntityType.TEXT_MENTION and self.user:
            return self.user.get_mention(entity_text)
        return entity_text
1257011
def _parseSimpleSelector(self, src):
        
        ctxsrc = src.lstrip()
        nsPrefix, src = self._getMatchResult(self.re_namespace_selector, src)
        name, src = self._getMatchResult(self.re_element_name, src)
        if name:
            pass # already *successfully* assigned
        elif src[:1] in self.SelectorQualifiers:
            name = '*'
        else:
            raise self.ParseError('Selector name or qualifier expected', src, ctxsrc)

        name = self.cssBuilder.resolveNamespacePrefix(nsPrefix, name)
        selector = self.cssBuilder.selector(name)
        while src and src[:1] in self.SelectorQualifiers:
            hash_, src = self._getMatchResult(self.re_hash, src)
            if hash_ is not None:
                selector.addHashId(hash_)
                continue

            class_, src = self._getMatchResult(self.re_class, src)
            if class_ is not None:
                selector.addClass(class_)
                continue

            if src.startswith('['):
                src, selector = self._parseSelectorAttribute(src, selector)
            elif src.startswith(':'):
                src, selector = self._parseSelectorPseudo(src, selector)
            else:
                break

        return src.lstrip(), selector
1175161
def parse(html):
    
    if not html:
        return html, []

    parser = HTMLToTelegramParser()
    parser.feed(_add_surrogate(html))
    text = helpers.strip_text(parser.text, parser.entities)
    return _del_surrogate(text), parser.entities
353340
def text(self, selector):
        

        result = self.__bs4.select(selector)

        return [r.get_text() for r in result] \
            if result.__len__() > 1 else \
            result[0].get_text() if result.__len__() > 0 else None
519142
function _sel(selector)
    {
        var f, out = [];
        if (typeof selector == "string")
        {
            while (selector != "")
            {
                f = selector.match(re_selector_fragment);
                if (f[0] == "") return null;
                out.push({ rel: f[1], tag: f[2], uTag: (f[2] || "").toUpperCase(), id: f[3], classes: (f[4]) ? f[4].split(".") : _undefined });
                selector = selector.substring(f[0].length);
            }
        }
        return out;
    }
125038
def parse_string(self):
        
        if self._parse_string is None:
            parse_text = self._element.xpath('parse/text()')
            if len(parse_text) > 0:
                self._parse_string = parse_text[0]
        return self._parse_string
1245665
public static String extractText(String html) {
        //return Jsoup.parse(text).text();
        html = replaceImgWithAlt(html);
        html = safeRemoveAllTags(html);
        
        html = unescapeHtml(html);
        
        return html;
    }
385977
def get_text(self, locator):
        
        text = self._get_text(locator)
        self._info("Element '%s' text is '%s' " % (locator, text))
        return text
64827
def markdown_to_text(body):
    
    # Turn our input into HTML
    md = markdown.markdown(body, extensions=[
        'markdown.extensions.extra'
    ])

    # Safely parse HTML so that we don't have to parse it ourselves
    soup = BeautifulSoup(md, 'html.parser')

    # Return just the text of the parsed HTML
    return soup.get_text()
1028520
def scrape(self, selector, cleaner=None, processor=None):
        """"""
        # Apply CSS or XPath expression to the selector
        selected = selector.xpath(self.selection) if self.xpath else selector.css(self.selection)
        # Extract the value and apply regular expression if specified
        value = selected.re(self.re) if self.re else selected.extract(raw=self.raw, cleaner=cleaner)
        return self._post_scrape(value, processor=processor)
1026703
def text(el, strip=True):
    
    if not el:
        return ""

    text = el.text
    if strip:
        text = text.strip()
    return text
548892
function selectedText(editor) {
    restoreRange(editor);
    if (ie) return getRange(editor).text;
    return getSelection(editor).toString();
  }