예제 #1
0
파일: core.py 프로젝트: burhan/mynt
    def _highlight(self, match):
        language, code = match.groups()
        formatter = HtmlFormatter(linenos='table')

        code = h.unescape_html(code.encode('utf-8')).decode('utf-8')

        try:
            code = highlight(code, get_lexer_by_name(language), formatter)
        except ClassNotFound:
            code = highlight(code, get_lexer_by_name('text'), formatter)

        return '<div class="code"><div>{0}</div></div>'.format(code)
예제 #2
0
파일: core.py 프로젝트: dkuntz2/fjord
 def _highlight(self, match):
         language, code = match.groups()
         formatter = HtmlFormatter(linenos=True)
         
         code = h.unescape_html(code.encode('utf-8')).decode('utf-8')
         
         try:
             code = highlight(code, get_lexer_by_name(language), formatter)
         except ClassNotFound:
             code = highlight(code, get_lexer_by_name('text'), formatter)
         
         return '<div class="code"><div>{0}</div></div>'.format(code)
예제 #3
0
파일: core.py 프로젝트: cblte/mynt
    def _highlight(self, match):
            logger.debug('>>  .... found a highlightcode')

            language, code = match.groups()
            formatter = HtmlFormatter()
            # added linenos to the config - user can decide
            # if specified then overwrite the default one
            if self.config['pygmentize_linenos']:
                plinenos=self.config['pygmentize_linenos']
                formatter = HtmlFormatter(linenos=plinenos)

            code = h.unescape_html(code.encode('utf-8')).decode('utf-8')

            try:
                code = highlight(code, get_lexer_by_name(language), formatter)
            except ClassNotFound:
                code = highlight(code, get_lexer_by_name('text'), formatter)

            return '<div class="code">{0}</div>'.format(code)