Upcoming events update
[mp-talk.git] / minted.sty
1 %%
2 %% This is file `minted.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% minted.dtx  (with options: `package')
8 %% Copyright 2010 Konrad Rudolph
9 %% 
10 %% This work may be distributed and/or modified under the
11 %% conditions of the LaTeX Project Public License, either version 1.3
12 %% of this license or (at your option) any later version.
13 %% The latest version of this license is in
14 %%   http://www.latex-project.org/lppl.txt
15 %% and version 1.3 or later is part of all distributions of LaTeX
16 %% version 2005/12/01 or later.
17 %% 
18 %% Additionally, the project may be distributed under the terms of the new BSD
19 %% license.
20 %% 
21 %% This work has the LPPL maintenance status `maintained'.
22 %% 
23 %% The Current Maintainer of this work is Konrad Rudolph.
24 %% 
25 %% This work consists of the files mints.dtx and mints.ins
26 %% and the derived file mints.sty.
27 \NeedsTeXFormat{LaTeX2e}
28 \ProvidesPackage{minted}[2011/08/30 v1.7 Yet another Pygments shim for LaTeX]
29 \RequirePackage{keyval}
30 \RequirePackage{fancyvrb}
31 \RequirePackage{color}
32 \RequirePackage{float}
33 \RequirePackage{ifthen}
34 \RequirePackage{calc}
35 \RequirePackage{ifplatform}
36 \ifwindows
37   \providecommand\DeleteFile[1]{\immediate\write18{del #1}}
38 \else
39   \providecommand\DeleteFile[1]{\immediate\write18{rm #1}}
40 \fi
41 \newboolean{AppExists}
42 \newcommand\TestAppExists[1]{
43   \ifwindows
44     \DeleteFile{\jobname.aex}
45     \immediate\write18{for \string^\@percentchar i in (#1.exe #1.bat #1.cmd)
46       do set >\jobname.aex <nul: /p x=\string^\@percentchar \string~$PATH:i>>\jobname.aex} %$
47     \newread\@appexistsfile
48     \immediate\openin\@appexistsfile\jobname.aex
49     \expandafter\def\expandafter\@tmp@cr\expandafter{\the\endlinechar}
50     \endlinechar=-1\relax
51     \readline\@appexistsfile to \@apppathifexists
52     \endlinechar=\@tmp@cr
53     \ifthenelse{\equal{\@apppathifexists}{}}
54      {\AppExistsfalse}
55      {\AppExiststrue}
56     \immediate\closein\@appexistsfile
57     \DeleteFile{\jobname.aex}
58 \immediate\typeout{file deleted}
59   \else
60     \immediate\write18{which #1 && touch \jobname.aex}
61     \IfFileExists{\jobname.aex}
62      {\AppExiststrue
63       \DeleteFile{\jobname.aex}}
64      {\AppExistsfalse}
65   \fi}
66 \newcommand\minted@resetoptions{}
67 \newcommand\minted@defopt[1]{
68   \expandafter\def\expandafter\minted@resetoptions\expandafter{%
69     \minted@resetoptions
70     \@namedef{minted@opt@#1}{}}}
71 \newcommand\minted@opt[1]{
72   \expandafter\detokenize%
73     \expandafter\expandafter\expandafter{\csname minted@opt@#1\endcsname}}
74 \newcommand\minted@define@opt[3][]{
75   \minted@defopt{#2}
76   \ifthenelse{\equal{#1}{}}{
77     \define@key{minted@opt}{#2}{\@namedef{minted@opt@#2}{#3}}}
78    {\define@key{minted@opt}{#2}[#1]{\@namedef{minted@opt@#2}{#3}}}}
79 \newcommand\minted@define@switch[3][]{
80   \minted@defopt{#2}
81   \define@booleankey{minted@opt}{#2}
82    {\@namedef{minted@opt@#2}{#3}}
83    {\@namedef{minted@opt@#2}{#1}}}
84 \minted@defopt{extra}
85 \newcommand\minted@define@extra[1]{
86   \define@key{minted@opt}{#1}{
87     \expandafter\def\expandafter\minted@opt@extra\expandafter{%
88       \minted@opt@extra,#1=##1}}}
89 \newcommand\minted@define@extra@switch[1]{
90   \define@booleankey{minted@opt}{#1}
91    {\expandafter\def\expandafter\minted@opt@extra\expandafter{%
92       \minted@opt@extra,#1}}
93    {\expandafter\def\expandafter\minted@opt@extra\expandafter{%
94       \minted@opt@extra,#1=false}}}
95 \minted@define@switch{texcl}{-P texcomments}
96 \minted@define@switch{mathescape}{-P mathescape}
97 \minted@define@switch{linenos}{-P linenos}
98 \minted@define@switch{startinline}{-P startinline}
99 \minted@define@switch[-P funcnamehighlighting=False]{funcnamehighlighting}{-P funcnamehighlighting}
100 \minted@define@opt{gobble}{-F gobble:n=#1}
101 \minted@define@opt{bgcolor}{#1}
102 \minted@define@extra{frame}
103 \minted@define@extra{framesep}
104 \minted@define@extra{framerule}
105 \minted@define@extra{rulecolor}
106 \minted@define@extra{numbersep}
107 \minted@define@extra{firstnumber}
108 \minted@define@extra{stepnumber}
109 \minted@define@extra{firstline}
110 \minted@define@extra{lastline}
111 \minted@define@extra{baselinestretch}
112 \minted@define@extra{xleftmargin}
113 \minted@define@extra{xrightmargin}
114 \minted@define@extra{fillcolor}
115 \minted@define@extra{tabsize}
116 \minted@define@extra{fontfamily}
117 \minted@define@extra{fontsize}
118 \minted@define@extra{fontshape}
119 \minted@define@extra{fontseries}
120 \minted@define@extra{formatcom}
121 \minted@define@extra{label}
122 \minted@define@extra@switch{numberblanklines}
123 \minted@define@extra@switch{showspaces}
124 \minted@define@extra@switch{resetmargins}
125 \minted@define@extra@switch{samepage}
126 \minted@define@extra@switch{showtabs}
127 \minted@define@extra@switch{obeytabs}
128 \newsavebox{\minted@bgbox}
129 \newenvironment{minted@colorbg}[1]{
130   \def\minted@bgcol{#1}
131   \noindent
132   \begin{lrbox}{\minted@bgbox}
133   \begin{minipage}{\linewidth-2\fboxsep}}
134  {\end{minipage}
135   \end{lrbox}%
136   \colorbox{\minted@bgcol}{\usebox{\minted@bgbox}}}
137 \newwrite\minted@code
138 \newcommand\minted@savecode[1]{
139   \immediate\openout\minted@code\jobname.pyg
140   \immediate\write\minted@code{#1}
141   \immediate\closeout\minted@code}
142 \newcommand\minted@pygmentize[2][\jobname.pyg]{
143   \def\minted@cmd{./pygmentize -l #2 -f latex -F tokenmerge
144     \minted@opt{gobble} \minted@opt{texcl} \minted@opt{mathescape}
145     \minted@opt{startinline} \minted@opt{funcnamehighlighting}
146     \minted@opt{linenos} -P "verboptions=\minted@opt{extra}"
147     -o \jobname.out.pyg #1}
148   \immediate\write18{\minted@cmd}
149   % For debugging, uncomment:
150   %\immediate\typeout{\minted@cmd}
151   \ifthenelse{\equal{\minted@opt@bgcolor}{}}
152    {}
153    {\begin{minted@colorbg}{\minted@opt@bgcolor}}
154   \input{\jobname.out.pyg}
155   \ifthenelse{\equal{\minted@opt@bgcolor}{}}
156    {}
157    {\end{minted@colorbg}}
158   \DeleteFile{\jobname.out.pyg}}
159 \newcommand\minted@usedefaultstyle{\usemintedstyle{default}}
160 \newcommand\usemintedstyle[1]{
161   \renewcommand\minted@usedefaultstyle{}
162   \immediate\write18{./pygmentize -S #1 -f latex > \jobname.pyg}
163   \input{\jobname.pyg}}
164 \newcommand\mint[3][]{
165   \DefineShortVerb{#3}
166   \minted@resetoptions
167   \setkeys{minted@opt}{#1}
168   \SaveVerb[aftersave={
169     \UndefineShortVerb{#3}
170     \minted@savecode{\FV@SV@minted@verb}
171     \minted@pygmentize{#2}
172     \DeleteFile{\jobname.pyg}}]{minted@verb}#3}
173 \newcommand\minted@proglang[1]{}
174 \newenvironment{minted}[2][]
175  {\VerbatimEnvironment
176   \renewcommand{\minted@proglang}[1]{#2}
177   \minted@resetoptions
178   \setkeys{minted@opt}{#1}
179   \begin{VerbatimOut}[codes={\catcode`\^^I=12}]{\jobname.pyg}}%
180  {\end{VerbatimOut}
181   \minted@pygmentize{\minted@proglang{}}
182   \DeleteFile{\jobname.pyg}}
183 \newcommand\inputminted[3][]{
184   \minted@resetoptions
185   \setkeys{minted@opt}{#1}
186   \minted@pygmentize[#3]{#2}}
187 \newcommand\newminted[3][]{
188   \ifthenelse{\equal{#1}{}}
189    {\def\minted@envname{#2code}}
190    {\def\minted@envname{#1}}
191   \newenvironment{\minted@envname}
192    {\VerbatimEnvironment\begin{minted}[#3]{#2}}
193    {\end{minted}}
194   \newenvironment{\minted@envname *}[1]
195    {\VerbatimEnvironment\begin{minted}[#3,##1]{#2}}
196    {\end{minted}}}
197 \newcommand\newmint[3][]{
198   \ifthenelse{\equal{#1}{}}
199    {\def\minted@shortname{#2}}
200    {\def\minted@shortname{#1}}
201   \expandafter\newcommand\csname\minted@shortname\endcsname[2][]{
202     \mint[#3,##1]{#2}##2}}
203 \newcommand\newmintedfile[3][]{
204   \ifthenelse{\equal{#1}{}}
205    {\def\minted@shortname{#2file}}
206    {\def\minted@shortname{#1}}
207   \expandafter\newcommand\csname\minted@shortname\endcsname[2][]{
208     \inputminted[#3,##1]{#2}{##2}}}
209 \newfloat{listing}{h}{lol}
210 \newcommand\listingscaption{Listing}
211 \floatname{listing}{\listingscaption}
212 \newcommand\listoflistingscaption{List of listings}
213 \providecommand\listoflistings{\listof{listing}{\listoflistingscaption}}
214 \AtBeginDocument{
215   \minted@usedefaultstyle}
216 \AtEndOfPackage{
217   \ifnum\pdf@shellescape=1\relax\else
218     \PackageError{minted}
219      {You must invoke LaTeX with the
220       -shell-escape flag}
221      {Pass the -shell-escape flag to LaTeX. Refer to the minted.sty
222       documentation for more information.}\fi
223   \TestAppExists{pygmentize}
224   \ifAppExists\else
225     \PackageError{minted}
226      {You must have `pygmentize' installed
227       to use this package}
228      {Refer to the installation instructions in the minted
229       documentation for more information.}
230   \fi}
231 \endinput
232 %%
233 %% End of file `minted.sty'.
This page took 0.021819 seconds and 4 git commands to generate.