(self, fragment, replace=False)
return out_string
Returns a formatted version of the given text, using the "token"
        objects in the given :class:`Fragment`.

        :param fragment: a :class:`Fragment` object representing a list of
            matches in the text.
        :param replace: if True, the original text corresponding to each
            match will be replaced with the value of the token object's
            ``text`` attribute.
Returns a formatted version of the given text, using the "token"
        objects in the given :class:`Fragment`.
Returns a formatted version of the given text using the token objects in the given : class : Fragment .
def format_fragment(self, fragment, replace=False):
        """Returns a formatted version of the given text, using the "token"
        objects in the given :class:`Fragment`.

        :param fragment: a :class:`Fragment` object representing a list of
            matches in the text.
        :param replace: if True, the original text corresponding to each
            match will be replaced with the value of the token object's
            ``text`` attribute.
        """

        output = []
        index = fragment.startchar
        text = fragment.text

        for t in fragment.matches:
            if t.startchar < index:
                continue
            if t.startchar > index:
                output.append(self._text(text[index:t.startchar]))
            output.append(self.format_token(text, t, replace))
            index = t.endchar
        output.append(self._text(text[index:fragment.endchar]))

        out_string = "".join(output)
        return out_string
def format_fragment ( self , fragment , replace = False ) : output = [ ] index = fragment . startchar text = fragment . text for t in fragment . matches : if t . startchar < index : continue if t . startchar > index : output . append ( self . _text ( text [ index : t . startchar ] ) ) output . append ( self . format_token ( text , t , replace ) ) index = t . endchar output . append ( self . _text ( text [ index : fragment . endchar ] ) ) out_string = "" . join ( output ) return out_string