* synopsis: ``%alpha{text}``
        * description: This function first ASCIIfies the given text, then all \
            non alphabet characters are replaced with whitespaces.
976154
def tmpl_alpha(self, text):
        
        text = self.tmpl_asciify(text)
        text = re.sub(r'[^a-zA-Z]+', ' ', text)
        return re.sub(r'\s+', ' ', text)
940955
def trim_whitespace(self, text):
        

        lines = text.split('\n')
        new_lines = [x.lstrip() for x in lines]

        return '\n'.join(new_lines)
517180
def collapse_whitespace(text):
    
    if text is None:
        return None
    if hasattr(text, 'xpath'):
        text = text.xpath('string()')
    text = re.sub('\s+', ' ', text)
    return text.strip()
1184094
def format_single_space_only(text):
    
    return " ".join([word for word in text.strip().split(" ") if len(word) >= 1])
78374
def handle_whitespace(text):
    
    """
    text = re_retab.sub(sub_retab, text)
    text = re_whitespace.sub('', text).strip()
    return text
1360995
function getPandocId (text) {
  text = text
    .replace(emojiRegex(), '') // Strip emojis
    .toLowerCase()
    .trim()
    .replace(/%25|%/ig, '')   // remove single % signs
    .replace(RE_ENTITIES, '') // remove xml/html entities
    .replace(RE_SPECIALS, '') // single chars that are removed but not [.-]
    .replace(/\s+/g, '-')     // whitespaces
    .replace(/^-+|-+$/g, '')  // heading/ tailing hyphen
    .replace(RE_CJK, '')      // CJK punctuations that are removed

  if (/^[0-9-]+$/.test(text)) {
    text = 'section'
  }
  return text
}
273770
def ansiformat(attr, text):
    
    result = []
    if attr[:1] == attr[-1:] == '+':
        result.append(codes['blink'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '*':
        result.append(codes['bold'])
        attr = attr[1:-1]
    if attr[:1] == attr[-1:] == '_':
        result.append(codes['underline'])
        attr = attr[1:-1]
    result.append(codes[attr])
    result.append(text)
    result.append(codes['reset'])
    return ''.join(result)
661874
def tokenize(self, text):
        '''
        
        '''
        start = -1
        tokens = []
        for i, character in enumerate(text):
            if character == ' ' or character == '\t':
                if start >= 0:
                    word = text[start:i]
                    tokens.append({
                        'word': word,
                        'original_text': word,
                        'char_begin': start,
                        'char_end': i})
                    start = -1
            else:
                if start < 0:
                    start = i
        if start >= 0:
            tokens.append({
                'word': text[start:len(text)],
                'original_text': text[start:len(text)],
                'char_begin': start,
                'char_end': len(text)
            })
        return tokens
63489
def alphanumeric(text):
    """"""
    return "".join([c for c in text if re.match(r'\w', c)])
1284404
def text(self, text):
        
        ret = u"".join(text.content)
        if 'url' in text.properties:
            return u"`%s`_" % ret
        if 'bold' in text.properties:
            return u"**%s**" % ret
        if 'italic' in text.properties:
            return u"*%s*" % ret
        if 'sub' in text.properties:
            return ur"\ :sub:`%s`\ " % ret
        if 'super' in text.properties:
            return ur"\ :sup:`%s`\ " % ret
        return ret
15579
function stripColon(text) {
    var i = text.indexOf(":");
    if (i >= 0) {
        text = text.substr(i).trim();
        if (text[1] == " ") {
            text = text.substr(1).trim();
        }
    }
    return text;
}
728693
def nl2br(self, text):
        
        if isinstance(text, bytes):
            return text.replace(b'\n', b'<br/>\n')
        else:
            return text.replace('\n', '<br/>\n')
1037791
def Text(text, font, color=pygame.Color(0, 0, 0), antialias=False, align="center"):
    
    assert align in ["center", "left", "right"]
    margin_l, margin_r = 1, 1
    if align == "left": margin_l = 0
    elif align == "right": margin_r = 0
    margin = Margin(margin_l, margin_r)
    color_key = pygame.Color(0, 0, 1) if pygame.Color(0, 0, 1) != color else 0x000002
    
    text_surfaces = _lmap(lambda text: _text(text, font=font, 
                                   color=color, antialias=antialias),
                                   map(methodcaller("strip"), text.split("\n")))
    w = max(surf.get_rect().w for surf in text_surfaces)
    h = sum(surf.get_rect().h for surf in text_surfaces)
    surf = compose((w, h), Fill(color_key))(LinLayout("v")(
        *_lmap(lambda s: Surface(margin)(s), text_surfaces)))
    surf.set_colorkey(color_key)
    return surf.convert_alpha()
693084
def remove_whitespace(self, html):
        
        # Does python have a better way to do exactly this?
        clean_html = html
        for char in ("\r", "\n", "\t"):
            clean_html = clean_html.replace(char, "")
        return clean_html
518793
function (text) {
			if (typeof text === 'undefined') {
				// Unescape characters
				if (node.C) {
					return node.C.replace(/\\([\\:\]])/g, '$1');
				} else {
					return '';
				}
			} else {
				// Escape characters
				node.C = text.replace(/[\\:\]]/g, '\\$&');
			}
		}
177272
function escapeCommonChars(text) {
  /**
   * Generate new non-escape expression (must happen at execution time because
   * we use `RegExp.exec`, which tracks it's own state internally).
   */
  const nonEscapeExpression = new RegExp(nonEscapePattern, 'gm');

  /**
   * Use `replaceWhen` to escape markdown entities only within substrings that
   * are eligible for escaping.
   */
  return replaceWhen(nonEscapeExpression, escapeAll, text, true);
}
596105
def slugify(in_string):
    
    try:
        u_in_string = six.text_type(in_string).lower()
    except UnicodeDecodeError:
        raise ValueError("We expects when in_string is str type," + \
                         "it is an ascii, but now it isn't. Use unicode " + \
                         "in this case.")
    # convert & to "and"
    u_in_string = re.sub('\&amp\;|\&', ' and ', u_in_string)
    # replace spaces by hyphen
    u_in_string = re.sub('[-\s]+', '-', u_in_string)
    # remove symbols that not in alphabet
    u_in_string = u''.join([symb for symb in u_in_string if symb in ALPHABET])
    # translify it
    out_string = translify(u_in_string)
    # remove non-alpha
    return re.sub('[^\w\s-]', '', out_string).strip().lower()