format a value to fit py3o's context

    * Handle linebreaks
559453
def format_py3o_val(value):
    
    value = force_unicode(value)
    value = escape(value)
    value = value.replace(u'\n', u'<text:line-break/>')
    return Markup(value)
3159
def linebreaks_safe(value, autoescape=True):
    
    if isinstance(value, string_types) and '\n' in value:
        return linebreaks_filter(value, autoescape=autoescape)

    return value
1223359
def format(self, data, **context):
        
        tokens = self.tokenize(data)
        full_context = self.default_context.copy()
        full_context.update(context)
        return self._format_tokens(tokens, None, **full_context).replace('\r', self.newline)
1196714
def format_float(value): # not used
    
    string = "{:g}".format(value).replace("e+", "e")
    string = re.sub("e(-?)0*(\d+)", r"e\1\2", string)
    return string
716538
def _unescape_str(value):
        

        if isinstance(value, int):
            return "%d" % value
        value = value.replace(r"\\", "\\")
        for i, j in ts3_escape.items():
            value = value.replace(j, i)
        return value
1225930
def _value_format(self, value):
        
        return '%s: %s' % (
            self.area_names.get(self.adapt_code(value[0]), '?'),
            self._y_format(value[1])
        )
1151200
def format_value(value,number_format):
    ""

    style,sufix,scale = decode_format(number_format)
    fmt = "{0:" + style + "}" + sufix

    return fmt.format(scale * value)
198307
def apply_markup(value, arg=None):
    
    if arg is not None:
        return formatter(value, filter_name=arg)
    return formatter(value)
912707
def _format_value(self, value):
        
        value, unit = self.py3.format_units(value, unit=self.unit, si=self.si_units)
        return self.py3.safe_format(self.format_value, {"value": value, "unit": unit})
609743
def format_header_cell(val):
    
    return re.sub('_', ' ', re.sub(r'(_Px_)', '(', re.sub(r'(_xP_)', ')', str(val) )))
745641
function format( value ) {
      // value was wrapped in array for parsing:
      try {
         return value.map( function( item ) {
            return JSON.stringify( item, null, 3 ).replace( NEWLINE_MATCHER, '\n' );
         } ).join( ',\n' );
      }
      catch( e ) {
         // value not JSON-compatible
         return value;
      }
   }
367489
def html_format(value):
    
    if not value:
        return ''
    elif MARKUP_LANGUAGE == 'markdown':
        return markdown(value)
    elif MARKUP_LANGUAGE == 'textile':
        return textile(value)
    elif MARKUP_LANGUAGE == 'restructuredtext':
        return restructuredtext(value)
    elif '</p>' not in value:
        return linebreaks(value)
    return value
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")
777931
def pretty_str(self, indent=0):
        
        indent = ' ' * indent
        values = '{{{}}}'.format(', '.join(map(pretty_str, self.value)))

        if self.parenthesis:
            return '{}({})'.format(indent, values)
        return '{}{}'.format(indent, values)
537974
def pformat_exc(self, exc):
        
        lines = []
        try:
            pre_nl = self.last_query.rindex("\n", 0, exc.loc) + 1
        except ValueError:
            pre_nl = 0
        try:
            post_nl = self.last_query.index("\n", exc.loc)
        except ValueError:
            post_nl = len(self.last_query)
        lines.append(self.last_query[:post_nl])
        lines.append(" " * (exc.loc - pre_nl) + "^")
        lines.append(str(exc))
        return "\n".join(lines)
226846
def PythonPercentFormat(format_str):
  """"""

  if format_str.startswith('printf '):
    fmt = format_str[len('printf '):]
    return lambda value: fmt % value
  else:
    return None
297539
function(str){
    var lines = str.match(/\n/g)
      , idx = str.lastIndexOf('\n');

    if (lines) this.lineno += lines.length;
    this.column = ~idx
      ? str.length - idx
      : this.column + str.length;
  }