diff options
author | EricFromCanada <eric3knibbe@gmail.com> | 2013-02-07 14:15:42 -0500 |
---|---|---|
committer | EricFromCanada <eric3knibbe@gmail.com> | 2013-02-07 14:15:42 -0500 |
commit | d10b666f5763c6a11394f5a1367cb6861eb16eff (patch) | |
tree | a30d19722a2cafb06d72e1beaebb60839780a1b1 /external | |
parent | 9ccfcc71026e7fd28fe96ed8461442105036a31a (diff) | |
parent | 054c464c70c115f476608a51bb0b4a931d1fa400 (diff) | |
download | pygments-d10b666f5763c6a11394f5a1367cb6861eb16eff.tar.gz |
1.6 merge
Diffstat (limited to 'external')
-rwxr-xr-x | external/autopygmentize | 64 | ||||
-rw-r--r-- | external/markdown-processor.py | 4 | ||||
-rw-r--r-- | external/moin-parser.py | 2 | ||||
-rw-r--r-- | external/rst-directive-old.py | 2 | ||||
-rw-r--r-- | external/rst-directive.py | 2 |
5 files changed, 69 insertions, 5 deletions
diff --git a/external/autopygmentize b/external/autopygmentize new file mode 100755 index 00000000..85c8dfd2 --- /dev/null +++ b/external/autopygmentize @@ -0,0 +1,64 @@ +#!/bin/sh +# Best effort auto-pygmentization with transparent decompression +# (c) Reuben Thomas 2012-2013 +# This program is in the public domain. + +# Strategy: first see if pygmentize can find a lexer; if not, ask file; if that finds nothing, fail +# Set the environment variable PYGMENTIZE_OPTS to configure pygments. + +# This program can be used as a .lessfilter for the less pager to auto-color less's output + +lexer=`pygmentize -N "$1"` +if [ "$lexer" = "text" ]; then + file_common_opts="--brief --dereference --uncompress" + + unset lexer + case `file --mime-type $file_common_opts "$1"` in + application/xml|image/svg+xml) lexer=xml;; + text/html) lexer=html;; + text/troff) lexer=nroff;; + text/x-asm) lexer=nasm;; + text/x-awk) lexer=awk;; + text/x-c) lexer=c;; + text/x-c++) lexer=cpp;; + text/x-diff) lexer=diff;; + text/x-fortran) lexer=fortran;; + text/x-gawk) lexer=gawk;; + text/x-java) lexer=java;; + text/x-lisp) lexer=common-lisp;; + text/x-lua) lexer=lua;; + text/x-makefile) lexer=make;; + text/x-msdos-batch) lexer=bat;; + text/x-nawk) lexer=nawk;; + text/x-pascal) lexer=pascal;; + text/x-perl) lexer=perl;; + text/x-php) lexer=php;; + text/x-po) lexer=po;; + text/x-python) lexer=python;; + text/x-ruby) lexer=ruby;; + text/x-shellscript) lexer=sh;; + text/x-tcl) lexer=tcl;; + text/x-tex|text/x-texinfo) lexer=latex;; # FIXME: texinfo really needs its own lexer + + # Types that file outputs which pygmentize didn't support as of file 5.11, pygments 1.6rc1 + # text/calendar + # text/PGP + # text/rtf + # text/texmacs + # text/x-bcpl + # text/x-info + # text/x-m4 + # text/x-vcard + # text/x-xmcd + esac +fi + +encoding=`file --brief --mime-encoding $file_common_opts "$1"` + +if [ -n "$lexer" ]; then + # FIXME: Specify input encoding rather than output encoding https://bitbucket.org/birkenfeld/pygments-main/issue/800 + zcat "$1" | pygmentize -O encoding=$encoding,outencoding=UTF-8 $PYGMENTIZE_OPTS -l $lexer + exit 0 +fi + +exit 1 diff --git a/external/markdown-processor.py b/external/markdown-processor.py index 0d939b67..12e64680 100644 --- a/external/markdown-processor.py +++ b/external/markdown-processor.py @@ -27,7 +27,7 @@ .. _Markdown: http://www.freewisdom.org/projects/python-markdown/ - :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -64,4 +64,4 @@ class CodeBlockPreprocessor(TextPreprocessor): code = code.replace('\n\n', '\n \n').replace('\n', '<br />') return '\n\n<div class="code">%s</div>\n\n' % code return self.pattern.sub( - repl, lines)
\ No newline at end of file + repl, lines) diff --git a/external/moin-parser.py b/external/moin-parser.py index 0bb9791c..6544da1b 100644 --- a/external/moin-parser.py +++ b/external/moin-parser.py @@ -31,7 +31,7 @@ If you do not want to do that and are willing to accept larger HTML output, you can set the INLINESTYLES option below to True. - :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ diff --git a/external/rst-directive-old.py b/external/rst-directive-old.py index 8e703faa..a074536f 100644 --- a/external/rst-directive-old.py +++ b/external/rst-directive-old.py @@ -31,7 +31,7 @@ .. _directive documentation: http://docutils.sourceforge.net/docs/howto/rst-directives.html - :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ diff --git a/external/rst-directive.py b/external/rst-directive.py index b54b03ef..5c04038d 100644 --- a/external/rst-directive.py +++ b/external/rst-directive.py @@ -31,7 +31,7 @@ .. _directive documentation: http://docutils.sourceforge.net/docs/howto/rst-directives.html - :copyright: Copyright 2006-2012 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ |