コード例 #1
0
ファイル: markup.py プロジェクト: wowgeeker/motor-blog
    def handle_endtag(self, tag):
        if self.data:
            # We've ended a <code> tag within <pre>.
            options, hl_lines = {}, []
            # Parts of self.data will have \n in them.
            data = ''.join(self.data)

            lines = data.split('\n')
            if ':::' in self.data[0]:
                firstline, lines = lines[0], lines[1:]
                options = self.parse_code_header(firstline)

            if options.get('highlight'):
                # Highlighted lines within the code example.
                hl_lines = options['highlight'].split(',')

            code = '\n'.join(lines)
            self.emit(self.highlight(code, options.get('lang'), hl_lines))
            self.data = []
        HTMLPassThrough.handle_endtag(self, tag)
コード例 #2
0
ファイル: markup.py プロジェクト: bantana/motor-blog
    def handle_endtag(self, tag):
        if self.data:
            # We've ended a <code> tag within <pre>.
            options, hl_lines = {}, []
            # Parts of self.data will have \n in them.
            data = ''.join(self.data)

            lines = data.split('\n')
            if ':::' in self.data[0]:
                firstline, lines = lines[0], lines[1:]
                options = self.parse_code_header(firstline)

            if options.get('highlight'):
                # Highlighted lines within the code example.
                hl_lines = options['highlight'].split(',')

            code = '\n'.join(lines)
            self.emit(self.highlight(code, options.get('lang'), hl_lines))
            self.data = []
        HTMLPassThrough.handle_endtag(self, tag)
コード例 #3
0
ファイル: markup.py プロジェクト: karpitsky/motor-blog
    def handle_endtag(self, tag):
        if self.data:
            options, hl_lines = {}, []
            # parts of self.data will have \n in them
            data = ''.join(self.data)

            # TODO: document the format we're parsing in README
            if ':::' in self.data[0]:
                lines = data.split('\n')
                firstline, lines = lines[0], lines[1:]
                options = self.parse_code_header(firstline)
                if options.get('highlight'):
                    # Highlighted lines within the code example
                    hl_lines = options['highlight'].split(',')

                code = '\n'.join(lines)
                self.emit(self.highlight(code, options.get('lang'), hl_lines))
            else:
                self.emit(self.plain(data, hl_lines))
            self.data = []
        HTMLPassThrough.handle_endtag(self, tag)