Beispiel #1
0
    def _printable(self, text, htmlsafe = False):
        clean = text.replace('\n', ' ')[
            :min(
                len(text),
                int(self.options.get('line-length', 30)),
            )
        ].strip()

        if htmlsafe:
            clean = _util.htmlsafe(clean)

        return clean
Beispiel #2
0
    def _printable(self, text, htmlsafe = False):
        ll = int(self.options.get('line-length', 30))
        clean = _re.sub(r'\s+', ' ', text).strip()

        if len(clean) > ll:
            om = self.options.get('omit-mode', 'middle')
            if om == 'start':
                clean = clean[len(clean) - ll:]
            elif om == 'middle':
                clean = clean[:ll / 2] + " ... " + clean[len(clean) - (ll / 2):]
            elif om == 'end':
                clean = clean[:ll]

        if htmlsafe:
            clean = _util.htmlsafe(clean)

        return clean
Beispiel #3
0
    def _printable(self, text, htmlsafe = False):
        ll = int(self.options.get('line-length', 30))
        clean = _re.sub(r'\s+', ' ', text).strip()

        if len(clean) > ll:
            om = self.options.get('omit-mode', 'middle')
            if om == 'start':
                clean = clean[len(clean) - ll:]
            elif om == 'middle':
                clean = clean[:int(ll / 2)] + " ... " + clean[len(clean) - int(ll / 2):]
            elif om == 'end':
                clean = clean[:ll]

        if htmlsafe:
            clean = _util.htmlsafe(clean)

        return clean