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)
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)
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)