Normalize links i.e. replace '<', '>' wrapping the link with some symbols
    so that '>' closing the link couldn't be mistakenly taken for quotation
    marker.

    Converts msg_body into a unicode
180887
def _replace_link_brackets(msg_body):
    
    if isinstance(msg_body, bytes):
        msg_body = msg_body.decode('utf8')

    def link_wrapper(link):
        newline_index = msg_body[:link.start()].rfind("\n")
        if msg_body[newline_index + 1] == ">":
            return link.group()
        else:
            return "@@%s@@" % link.group(1)

    msg_body = re.sub(RE_LINK, link_wrapper, msg_body)
    return msg_body
1085129
def normalize_text(text: str) -> str:
    
    return ' '.join([token
                     for token in text.lower().strip(STRIPPED_CHARACTERS).split()
                     if token not in IGNORED_TOKENS])
522568
def normalize_links
      stack = @links.dup

      @links.clear

      while link = stack.pop
        relationship = case link
          when Symbol, String
            @relationships[link]
          else
            link
        end

        if relationship.respond_to?(:links)
          stack.concat(relationship.links)
        elsif !@links.include?(relationship)
          @links << relationship
        end
      end

      @links.reverse!
    end
459832
def translate_links(self, text, in_comment=None):
        
        def replace_link(matchobj):
            ref = matchobj.group(1)
            return '<a href = "%s">%s</a>' % (
                    self.translate_ref_to_url(ref, in_comment), ref)
        return re.sub('{@link ([\w#]+)}', replace_link, text)
388683
def normalize_url(url: str) -> str:
    
    if url.startswith('/'):
        url = url[1:]

    if url.endswith('/'):
        url = url[:-1]

    return url
661139
def _transform(self, data, escape_html, replace_links, replace_cosmetic, transform_newlines, **context):
        
        url_matches = {}
        if self.replace_links and replace_links:
            # If we're replacing links in the text (i.e. not those in [url] tags) then we need to be
            # careful to pull them out before doing any escaping or cosmetic replacement.
            pos = 0
            while True:
                match = _url_re.search(data, pos)
                if not match:
                    break
                # Replace any link with a token that we can substitute back in after replacements.
                token = '{{ bbcode-link-%s }}' % len(url_matches)
                url_matches[token] = self._link_replace(match, **context)
                start, end = match.span()
                data = data[:start] + token + data[end:]
                # To be perfectly accurate, this should probably be len(data[:start] + token), but
                # start will work, because the token itself won't match as a URL.
                pos = start
        if escape_html:
            data = self._replace(data, self.REPLACE_ESCAPE)
        if replace_cosmetic:
            data = self._replace(data, self.REPLACE_COSMETIC)
        # Now put the replaced links back in the text.
        for token, replacement in url_matches.items():
            data = data.replace(token, replacement)
        if transform_newlines:
            data = data.replace('\n', '\r')
        return data
525590
def normalize_linefeeds(self, a_string):
        
        newline = re.compile("(\r\r\r\n|\r\r\n|\r\n|\n\r)")
        a_string = newline.sub(self.RESPONSE_RETURN, a_string)
        if self.RESPONSE_RETURN == "\n":
            # Convert any remaining \r to \n
            return re.sub("\r", self.RESPONSE_RETURN, a_string)
1055616
def url_quote(string, charset='utf-8', errors='strict', safe='/:'):
    
    if not isinstance(string, (text_type, bytes, bytearray)):
        string = text_type(string)
    if isinstance(string, text_type):
        string = string.encode(charset, errors)
    if isinstance(safe, text_type):
        safe = safe.encode(charset, errors)
    safe = frozenset(bytearray(safe) + _always_safe)
    rv = bytearray()
    for char in bytearray(string):
        if char in safe:
            rv.append(char)
        else:
            rv.extend(('%%%02X' % char).encode('ascii'))
    return to_native(bytes(rv))
716119
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xb7', '')
		string = string.replace(u'\xa0', ' ')
		string = string.replace('selten: ', '')
		string = string.replace('Alte Rechtschreibung', '')
		string = string.strip()
		return string
188092
function normalizeUrl (url) {
  if (!url || /per_page=/.test(url)) return url
  /* istanbul ignore next */
  if ((/&/.test(url) && !/&$/.test(url)) || (!/\?$/.test(url) && /\?/.test(url))) {
    return url + '&per_page=100'
  }
  return /\?$/.test(url) ? url + 'per_page=100' : url + '?per_page=100'
}
931137
def normalize(string)
      new_body = normalize_entities(string)
      # Fix mismatched tags. Yes, it's faster to do it per-message
      # than all at once.
      new_body = Pipio::TagBalancer.new(new_body).balance
      if @sender_alias[0,3] == '***'
        # "***<alias>" is what pidgin sets as the alias for a /me action
        @sender_alias.slice!(0,3)
        new_body = "*#{new_body}*"
      end

      new_body
    end
385672
def normalize(string: Text) -> Text:
    

    string = string.lower()
    string = unidecode(string)
    string = RE_WHITESPACES.sub(' ', string).strip()

    return string
557459
def _normalize_string(raw_str):
  
  return " ".join(
      token.strip()
      for token in tokenizer.encode(text_encoder.native_to_unicode(raw_str)))
54481
def quotemeta(text):
    
    text = re.sub(r'/', '//', text)
    text = re.sub(r'\\{', '/{', text)
    text = re.sub(r'\\}', '/}', text)
    return text
782991
def normalize_UNTL(subject):
    """"""
    subject = subject.strip()
    subject = re.sub(r'[\s]+', ' ', subject)
    return subject
65552
def _normalize(self, string):
		'''  '''

		string = string.replace(u'\xa0', '')
		string = string.strip()
		return string
323767
def normalize_locale_code(locale: Union[Locale, str]) -> str:
    
    if not isinstance(locale, Locale):
        locale = Locale.parse(locale.replace('-', '_'))
    return str(locale)