Stringify text. Supports named entities in `settings.encode: true` mode:  ```markdown AT&amp;T ```  Supports numbered entities in `settings.encode: numbers` mode:  ```markdown AT&#x26;T ```
487452
function text(node, parent) {
  return this.encode(this.escape(node.value, node, parent), node)
}
1105121
def slugify(text, sep='-'):
    """"""
    text = stringify(text)
    if text is None:
        return None
    text = text.replace(sep, WS)
    text = normalize(text, ascii=True)
    if text is None:
        return None
    return text.replace(WS, sep)
601055
def _from_docstring_md(doc):
    

    def format_fn(line, status):
        """ format function """

        def fix_tags(line):
            # In markdown we need to escape < > and & for display
            # but we don't want to do this is the value is quoted
            # by backticks ``

            def fn(match):
                # swap matched chars
                found = match.group(1)
                if found == "<":
                    return "&lt;"
                if found == ">":
                    return "&gt;"
                if found == "&":
                    return "&amp;"
                return match.group(0)

            return re_from_tag.sub(fn, line)

        if re_from_data.match(line):
            line = re_from_data.sub(r"**\1** ", line)
            status["add_line"] = True
        line = re_from_defaults.sub(r"*\1*", line)
        if status["listing"]:
            # parameters
            if re_from_param.match(line):
                m = re_from_param.match(line)
                line = "  - `{}` {}".format(m.group(1), fix_tags(m.group(3)))
            # status items
            elif re_from_status.match(line):
                m = re_from_status.match(line)
                line = "  - `{}` {}".format(m.group(1), fix_tags(m.group(3)))
            # bullets
            elif re_from_item.match(line):
                line = re_from_item.sub(r"  -", fix_tags(line))
            # is continuation line
            else:
                line = fix_tags(line)
                line = " " * 4 + line.lstrip()
        else:
            line = fix_tags(line)
        return line

    return _reformat_docstring(doc, format_fn, code_newline="\n")
972928
function slugifyText(str) {
        str = str.replace(/^\s+|\s+$/g, '') // trim
        .toLowerCase().replace(/\./g, '-') // Replace a dot for a -
        .replace(/\*/g, '-') // Replace a * for a -
        .replace(/\+/g, '-'); // Replace a + for a -

        // Remove accents, swap ñ for n, etc
        var from = 'àáäâãèéëêìíïîòóöôõùúüûýÿñç·/_,:;';
        var to = 'aaaaaeeeeiiiiooooouuuuyync------';

        for (var i = 0, len = from.length; i < len; i += 1) {
            str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
        }

        str = str.replace(/[^a-z0-9 -]/g, '') // Remove invalid chars
        .replace(/\s+/g, '-') // Collapse whitespace and replace by -
        .replace(/-+/g, '-'); // Collapse dashes

        if (str.charAt(0) === '-') str = str.substr(1);
        if (str.charAt(str.length - 1) === '-') str = str.substr(0, str.length - 1);

        return str;
    }
882376
def render_markdown(self, text, context=github.GithubObject.NotSet):
        
        assert isinstance(text, (str, unicode)), text
        assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context
        post_parameters = {
            "text": text
        }
        if context is not github.GithubObject.NotSet:
            post_parameters["mode"] = "gfm"
            post_parameters["context"] = context._identity
        status, headers, data = self.__requester.requestJson(
            "POST",
            "/markdown",
            input=post_parameters
        )
        return data
1361882
def _stringify_number(v):
    '''
    
    '''
    if isinstance(v, (float, Decimal)):
        if math.isinf(v) and v > 0:
            v = 'Infinity'
        elif math.isinf(v) and v < 0:
            v = '-Infinity'
        else:
            v = '{:f}'.format(v)
    elif isinstance(v, BinarySize):
        v = '{:d}'.format(int(v))
    elif isinstance(v, int):
        v = '{:d}'.format(v)
    else:
        v = str(v)
    return v
640150
function parseText(text) {
  text = text.replace(/\n/g, '')
  /* istanbul ignore if */
  if (!tagRE.test(text)) {
    return null
  }
  var tokens = []
  var lastIndex = tagRE.lastIndex = 0
  var match, index, html, value, first, oneTime
  /* eslint-disable no-cond-assign */
  while (match = tagRE.exec(text)) {
  /* eslint-enable no-cond-assign */
    index = match.index
    // push text token
    if (index > lastIndex) {
      tokens.push({
        value: text.slice(lastIndex, index)
      })
    }
    // tag token
    html = htmlRE.test(match[0])
    value = html ? match[1] : match[2]
    first = value.charCodeAt(0)
    oneTime = first === 42 // *
    value = oneTime
      ? value.slice(1)
      : value
    tokens.push({
      tag: true,
      value: value.trim(),
      html: html,
      oneTime: oneTime
    })
    lastIndex = index + match[0].length
  }
  if (lastIndex < text.length) {
    tokens.push({
      value: text.slice(lastIndex)
    })
  }
  return tokens
}
709267
def encode(string):
		

		result=".".join([ str(ord(s)) for s in string ])
		return  "%s." % (len(string)) + result
301477
function (text, attr) {
    if (attr === void 0) { attr = '1'; }
    var do_quotes;
    var do_backticks;
    var do_dashes;
    var do_ellipses;
    var do_stupefy;
    if (typeof attr === 'number') {
      attr = attr.toString();
    }
    else {
      attr = attr.replace(/\s/g, '');
    }
    if (attr === '0') {
      // Do nothing
      return text;
    }
    else if (attr === '1') {
      // Do everything, turn all options on.
      do_quotes = 1;
      do_backticks = 1;
      do_dashes = 1;
      do_ellipses = 1;
    }
    else if (attr === '2') {
      // Do everything, turn all options on, use old school dash shorthand.
      do_quotes = 1;
      do_backticks = 1;
      do_dashes = 3;
      do_ellipses = 1;
    }
    else if (attr === '3') {
      // Do everything, turn all options on, use inverted old school dash shorthand.
      do_quotes = 1;
      do_backticks = 1;
      do_dashes = 3;
      do_ellipses = 1;
    }
    else if (attr === '-1') {
      // Special "stupefy" mode.
      do_stupefy = 1;
    }
    else {
      for (var i = 0; i < attr.length; i++) {
        var c = attr[i];
        if (c === 'q') {
          do_quotes = 1;
        }
        if (c === 'b') {
          do_backticks = 1;
        }
        if (c === 'B') {
          do_backticks = 2;
        }
        if (c === 'd') {
          do_dashes = 1;
        }
        if (c === 'D') {
          do_dashes = 2;
        }
        if (c === 'i') {
          do_dashes = 3;
        }
        if (c === 'e') {
          do_ellipses = 1;
        }
      }
    }
    if (do_dashes) {
      text = text.replace(/&#8211;/g, '\u2013'); // en-dash
      text = text.replace(/&#8212;/g, '\u2014'); // em-dash
    }
    if (do_quotes || do_backticks) {
      text = text.replace(/&#8216;/g, '\u2018'); // open single quote
      text = text.replace(/&#8217;/g, '\u2019'); // close single quote
      text = text.replace(/&#8220;/g, '\u201c'); // open double quote
      text = text.replace(/&#8221;/g, '\u201d'); // close double quote
    }
    if (do_ellipses) {
      text = text.replace(/&#8230;/g, '\u2026'); // ellipsis
    }
    return text;
  }
1143980
function nativeDecode(text) {
      var elm;

      elm = document.createElement("div");
      elm.innerHTML = text;

      return elm.textContent || elm.innerText || text;
    }
90747
private static String encodeHTMLEntities(String string) {
		if (string == null) {
			return null;
		}
		try {
			return URLEncoder.encode(string, Charset.defaultCharset().displayName());
		} catch (UnsupportedEncodingException exception) {
			return string;
		}
	}
1144552
function doCodeSpans(text) {

        text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function(wholeMatch,m1,m2,m3,m4) {

            var c = m3;
            c = c.replace(/^([ \t]*)/g,"");
            c = c.replace(/[ \t]*$/g,"");
            c = encodeCode(c);

            return m1+"<code>"+c+"</code>";
        });

        return text;
    }
708976
function addAnchors(text) {
        if(text.charAt(0) != '\x02')
            text = '\x02' + text;
        if(text.charAt(text.length - 1) != '\x03')
            text = text + '\x03';
        return text;
    }
529948
def slugify(value, separator='-', max_length=0, word_boundary=False,
            entities=True, decimal=True, hexadecimal=True):
    '''
    '''
    value = normalize('NFKD', to_string(value, 'utf-8', 'ignore'))
    if unidecode:
        value = unidecode(value)

    # character entity reference
    if entities:
        value = CHAR_ENTITY_REXP.sub(
            lambda m: chr(name2codepoint[m.group(1)]), value)

    # decimal character reference
    if decimal:
        try:
            value = DECIMAL_REXP.sub(lambda m: chr(int(m.group(1))), value)
        except Exception:
            pass

    # hexadecimal character reference
    if hexadecimal:
        try:
            value = HEX_REXP.sub(lambda m: chr(int(m.group(1), 16)), value)
        except Exception:
            pass

    value = value.lower()

    value = REPLACE1_REXP.sub('', value)
    value = REPLACE2_REXP.sub('-', value)

    # remove redundant -
    value = REMOVE_REXP.sub('-', value).strip('-')

    # smart truncate if requested
    if max_length > 0:
        value = smart_truncate(value, max_length, word_boundary, '-')

    if separator != '-':
        value = value.replace('-', separator)

    return value
141229
def _encode_text(name, value, dummy0, dummy1):
    """"""
    value = _utf_8_encode(value)[0]
    return b"\x02" + name + _PACK_INT(len(value) + 1) + value + b"\x00"
137836
def _escape_markdown_literals(string):
    
    literals = list("\\`*_{}[]()<>#+-.!:|")
    escape = lambda c: '\\' + c if c in literals else c
    return "".join(map(escape, string))
1156107
def replace_character_sequence_with_hyphen(string, mode: "default")
      replaceable_char =
        case mode
        when "raw"
          SLUGIFY_RAW_REGEXP
        when "pretty"
          # "._~!$&'()+,;=@" is human readable (not URI-escaped) in URL
          # and is allowed in both extN and NTFS.
          SLUGIFY_PRETTY_REGEXP
        when "ascii"
          # For web servers not being able to handle Unicode, the safe
          # method is to ditch anything else but latin letters and numeric
          # digits.
          SLUGIFY_ASCII_REGEXP
        else
          SLUGIFY_DEFAULT_REGEXP
        end

      # Strip according to the mode
      string.gsub(replaceable_char, "-")
    end