Home | Trees | Indices | Help |
|
---|
|
1 # This program is free software; you can redistribute it and/or modify it under 2 # the terms of the GNU General Public License as published by the Free Software 3 # Foundation; either version 2 of the License, or (at your option) any later 4 # version. 5 # 6 # This program is distributed in the hope that it will be useful, but WITHOUT 7 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 8 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 9 # 10 # You should have received a copy of the GNU General Public License along with 11 # this program; if not, write to the Free Software Foundation, Inc., 12 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 13 # copyright 2006-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved. 14 # contact http://www.logilab.fr/ -- mailto:contact@logilab.fr 15 # 16 # This file is part of logilab-mtconverter. 17 # 18 # logilab-mtconverter is free software: you can redistribute it and/or modify it 19 # under the terms of the GNU Lesser General Public License as published by the 20 # Free Software Foundation, either version 2.1 of the License, or (at your 21 # option) any later version. 22 # 23 # logilab-mtconverter is distributed in the hope that it will be useful, but 24 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 26 # for more details. 27 # 28 # You should have received a copy of the GNU Lesser General Public License along 29 # with logilab-mtconverter. If not, see <http://www.gnu.org/licenses/>. 30 """interface pygments (http://pygments.org/) with mtconverter""" 31 32 __docformat__ = "restructuredtext en" 33 34 from logilab.mtconverter.transform import Transform 35 36 from pygments import highlight 37 from pygments.lexers import LEXERS, get_lexer_for_mimetype as mtlexer 38 from pygments.formatters import HtmlFormatter, LatexFormatter, RtfFormatter, SvgFormatter 39 40 # hint: changes MIMETYPES before registering pygments transforms if you don't 41 # want all available inputs 42 mimetypes = sorted(set([mt for _, _, _, _, mimetypes in LEXERS.itervalues() 43 for mt in mimetypes])) 4446 """note: this transform use CSS classes which can be obtained using: 47 formatter.get_style_defs() 48 """ 49 inputs = mimetypes 50 output = 'text/html'54 5552 lexer = mtlexer(trdata.mimetype, encoding=trdata.encoding) 53 return highlight(trdata.decode(force=True), lexer, HtmlFormatter())57 inputs = mimetypes 58 output = 'text/x-latex'62 63 70 77 78 79 transform_classes = (PygmentsHTMLTransform, PygmentsLatexTransform, 80 PygmentsRTFTransform, PygmentsSVGTransform) 8160 lexer = mtlexer(trdata.mimetype, encoding=trdata.encoding) 61 return highlight(trdata.decode(force=True), lexer, LatexFormatter())
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Mon Mar 14 19:07:57 2016 | http://epydoc.sourceforge.net |