コード例 #1
0
    def _fill_text(self, text, width, indent):
        text = (re.compile('\[quote\].*?\[\/quote\]', re.DOTALL).sub(
            lambda match: (match.group(0).replace('\n', '[QUOTE:NEWLINE]')),
            text))

        text = '\n'.join(
            [indent + line for line in self._split_lines(text, width)])

        text = (re.compile('\[quote\](.*?)\[\/quote\]', re.DOTALL).sub(
            lambda match: TERMINAL.green(
                match.group(1).replace('\n', ' ').replace(
                    '[QUOTE:NEWLINE]', TERMINAL.normal + '\n    ' + TERMINAL.
                    green).rstrip(' ').strip('\n')), text))
        return text
コード例 #2
0
ファイル: formatter.py プロジェクト: 4teamwork/ftw.upgrade
    def _fill_text(self, text, width, indent):
        text = (re.compile('\[quote\].*?\[\/quote\]', re.DOTALL)
                .sub(lambda match: (
                    match.group(0)
                    .replace('\n', '[QUOTE:NEWLINE]')),
                     text))

        text = '\n'.join([indent + line for line
                          in self._split_lines(text, width)])

        text = (re.compile('\[quote\](.*?)\[\/quote\]', re.DOTALL)
                .sub(lambda match: TERMINAL.green(
                    match.group(1)
                    .replace('\n', ' ')
                    .replace('[QUOTE:NEWLINE]',
                             TERMINAL.normal + '\n    ' + TERMINAL.green)
                    .rstrip(' ').strip('\n')),
                     text))
        return text