From 4c7c93512d5ad99119fc38035815ba54a17605a5 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 18 Sep 2011 22:29:01 +0000 Subject: minuted 1.7 (17sep11) git-svn-id: svn://tug.org/texlive/trunk@24002 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/minted/Makefile | 38 +++ Master/texmf-dist/doc/latex/minted/minted.pdf | Bin 357277 -> 353283 bytes Master/texmf-dist/source/latex/minted/Makefile | 36 -- Master/texmf-dist/source/latex/minted/minted.dtx | 414 ++++++++++++++++------- Master/texmf-dist/source/latex/minted/minted.ins | 8 +- Master/texmf-dist/tex/latex/minted/minted.sty | 46 ++- 6 files changed, 369 insertions(+), 173 deletions(-) create mode 100644 Master/texmf-dist/doc/latex/minted/Makefile delete mode 100644 Master/texmf-dist/source/latex/minted/Makefile (limited to 'Master/texmf-dist') diff --git a/Master/texmf-dist/doc/latex/minted/Makefile b/Master/texmf-dist/doc/latex/minted/Makefile new file mode 100644 index 00000000000..bb8877d025a --- /dev/null +++ b/Master/texmf-dist/doc/latex/minted/Makefile @@ -0,0 +1,38 @@ +TEXFLAGS = -e '$$pdflatex=q/pdflatex %O -shell-escape %S/' -pdf +LATEXMK = latexmk + +PACKAGE = minted.dtx \ + minted.ins \ + minted.pdf \ + README \ + Makefile + +.PHONY: minted all doc dist clean cleanall + +minted: minted.sty + +doc: minted.pdf + +all: minted doc + +minted.sty: minted.ins minted.dtx + tex minted.ins + +minted.pdf: minted.sty minted.gls minted.dtx + $(LATEXMK) $(TEXFLAGS) minted.dtx + +minted.gls: minted.glo + makeindex -s gglo.ist -o minted.gls minted.glo + +minted.glo: minted.dtx minted.sty + $(LATEXMK) $(TEXFLAGS) minted.dtx + +dist: $(PACKAGE) + @$(RM) minted.zip + @zip minted.zip $(PACKAGE) + +clean: + @$(RM) *.aux *.log *.out *.toc *.fdb_latexmk *.ilg *.glo *.gls *.lol + +cleanall: clean + @$(RM) minted.sty minted.zip diff --git a/Master/texmf-dist/doc/latex/minted/minted.pdf b/Master/texmf-dist/doc/latex/minted/minted.pdf index 063f505e01b..892bd29b400 100644 Binary files a/Master/texmf-dist/doc/latex/minted/minted.pdf and b/Master/texmf-dist/doc/latex/minted/minted.pdf differ diff --git a/Master/texmf-dist/source/latex/minted/Makefile b/Master/texmf-dist/source/latex/minted/Makefile deleted file mode 100644 index 8f051d4535d..00000000000 --- a/Master/texmf-dist/source/latex/minted/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -TEXFLAGS = -e '$$pdflatex=q/pdflatex %O -shell-escape %S/' -pdf -LATEXMK = latexmk - -PACKAGE = minted.dtx \ - minted.ins \ - minted.pdf \ - README \ - Makefile - -.PHONY: all doc dist clean cleanall - -all: minted.sty minted.pdf - -doc: minted.pdf - -minted.sty: minted.ins minted.dtx - echo y | tex minted.ins - -minted.pdf: minted.sty minted.gls minted.dtx - $(LATEXMK) $(TEXFLAGS) minted.dtx - -minted.gls: minted.glo - makeindex -s gglo.ist -o minted.gls minted.glo - -minted.glo: minted.dtx minted.sty - $(LATEXMK) $(TEXFLAGS) minted.dtx - -dist: $(PACKAGE) - @$(RM) minted.zip - @zip minted.zip $(PACKAGE) - -clean: - @$(RM) *.aux *.log *.out *.toc *.fdb_latexmk *.ilg *.glo *.gls *.lol - -cleanall: clean - @$(RM) minted.sty minted.zip diff --git a/Master/texmf-dist/source/latex/minted/minted.dtx b/Master/texmf-dist/source/latex/minted/minted.dtx index fcde9e66f46..483d1684495 100644 --- a/Master/texmf-dist/source/latex/minted/minted.dtx +++ b/Master/texmf-dist/source/latex/minted/minted.dtx @@ -1,6 +1,6 @@ % \iffalse meta-comment % minted.dtx -% Copyright 2010 Konrad Rudolph +% Copyright 2010-2011 Konrad Rudolph % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -23,7 +23,7 @@ % Nanos gigantum humeris insidentes. % % Special thanks to Philipp Stephani and the rest of the guys from -% comp.text.tex. +% comp.text.tex and tex.stackexchange.com % \fi % \iffalse %<*driver> @@ -32,11 +32,11 @@ %<*package> \NeedsTeXFormat{LaTeX2e} % -\ProvidesPackage{minted}[2010/01/27 v1.6 Yet another Pygments shim for LaTeX] +\ProvidesPackage{minted}[2011/09/17 v1.7 Yet another Pygments shim for LaTeX] % \RequirePackage{keyval} \RequirePackage{fancyvrb} -\RequirePackage{color} +\RequirePackage{xcolor} \RequirePackage{float} \RequirePackage{ifthen} \RequirePackage{calc} @@ -55,13 +55,36 @@ \usepackage{hyperref} \usepackage{microtype} +\def\MacroFont{% + \fontencoding\encodingdefault% + \fontfamily\ttdefault% + \fontseries\mddefault% + \fontshape\updefault% + \small} + +^^A FIXME This is incredibly hacky and overrides size commands around tt-text. +^^A But I don't get the font inside the main body to change otherwise. :-( +\let\mintedttold\ttfamily +\def\ttfamily{\mintedttold\fontsize{9}{9}\selectfont} + +\definecolor{minted@mint}{HTML}{4B6121} +\definecolor{minted@samplebg}{HTML}{F0F0E0} +\colorlet{minted@linkcolor}{minted@mint} + +\def\PrintDescribeMacro#1{\strut \MacroFont\textcolor{minted@linkcolor}{\string #1\ }} +\let\PrintDescribeEnv\PrintDescribeMacro +\let\PrintMacroName\PrintDescribeMacro +\let\PrintEnvName\PrintDescribeEnv +\def\theCodelineNo{\textcolor{minted@linkcolor}{\sffamily\footnotesize\oldstylenums{\arabic{CodelineNo}}}} + \hypersetup{ pdftitle=The minted package: Highlighted source code in LaTeX, pdfauthor=Konrad Rudolph, pdfsubject={Minted LaTeX package manual}, + allcolors=minted@linkcolor, } -% Shamelessly stolen from http://blog.karssen.org/2009/11/15/a-latex-example-environment/ +^^A Shamelessly stolen from http://blog.karssen.org/2009/11/15/a-latex-example-environment/ \newenvironment{example} {\VerbatimEnvironment \begin{VerbatimOut}[gobble=3]{example.out}} @@ -69,18 +92,33 @@ \vspace{1ex} \setlength{\parindent}{0pt} \fbox{\begin{minipage}{0.5\linewidth} - \small\inputminted[resetmargins]{latex}{example.out} + \inputminted[resetmargins]{latex}{example.out} \end{minipage} \hspace{0.05\linewidth} \begin{minipage}{0.4\linewidth} - \small\input{example.out} + \input{example.out} \end{minipage} \vspace{1ex}}} -\newenvironment{optionlist} - {\begin{list}{}{\renewcommand\makelabel[1]{\textsf{##1}:\quad}} - \DeleteShortVerb{\|}\MakeShortVerb{\+}} - {\end{list}\DeleteShortVerb{\+}\MakeShortVerb{\|}} +\makeatletter ^^A ?!? Needed, no idea why. +\def\minted@printopt#1(#2) (#3){% + \leavevmode% + \marginpar{\raggedleft\texttt{\textcolor{minted@linkcolor}{#1}}\ }% + \textsf{(#2)}\hfill(default: #3)\\} + +\newenvironment{optionlist}{% + \par% + \newcommand*\mintednext{}% + \renewcommand*\item[1][]{% + \mintednext% + \renewcommand*\mintednext{\par}% + \minted@printopt##1% + \ignorespaces} + \DeleteShortVerb{\|}% + \MakeShortVerb{\+}}{% + \DeleteShortVerb{\+}% + \MakeShortVerb{\|}% + \par} \newcommand\thestyle{trac} \usemintedstyle{\thestyle} @@ -102,7 +140,7 @@ % \newcommand\pkg[1]{\textsf{#1}} % \newcommand\app[1]{\textsf{#1}} % -% \title{The \pkg{minted} package:\\Highlighted source code in \LaTeX +% \title{The \textcolor{minted@mint}{\pkg{minted}} package:\\Highlighted source code in \LaTeX % \thanks{This document corresponds to \pkg{minted}~\fileversion, last changed~\filedate.}} % \author{Konrad Rudolph\\\texttt{konrad\char`\_rudolph@madrat.net}} % \date{\filedate} @@ -122,11 +160,12 @@ % % \fvset{ % codes={\catcode`\%=9}, ^^A Ignore initial |%| -% numbersep=5pt +% numbersep=5pt, +% fontsize=\small % } % \setlength{\fboxsep}{1ex} % -% +% \mbox{}\newpage % \section{Introduction} % % \pkg{minted} is a package that allows formatting source code in \LaTeX. @@ -136,7 +175,7 @@ % code % \end{minted} % \end{VerbatimOut} -% \inputminted[gobble=2]{latex}{minted.doc.out} +% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out} % % will highlight a piece of code in a chosen language. % The display can be customized by a number of arguments and colour schemes. @@ -157,10 +196,10 @@ % % \begin{minted}[gobble=3]{ruby} % class Foo -% def init -% pi = Math::PI -% @var = "Pi is approx. #{pi}" -% end +% def init +% pi = Math::PI +% @var = "Pi is approx. #{pi}" +% end % end % \end{minted} % @@ -172,6 +211,8 @@ % % \section{Installation} % +% \subsection{Prerequisites} +% % \app{Pygments} is written in Python so make sure that at least Python 2.6 is installed on you system: % % \begin{Verbatim}[gobble=3,commandchars=\\\{\}] @@ -194,9 +235,54 @@ % 1.2.) % % +% \subsection{Required packages} +% +% \pkg{minted} requires the following packages to be available and reasonably up to date on your system, all of which ship with recent \TeX{} distributions: +% +% \begingroup +% \setlength\parskip{0pt} +% \setlength\topsep{0pt} +% \begin{list}{\textrm{\labelitemi}}{\ttfamily} +% \item keyval +% \item fancyvrb +% \item xcolor +% \item float +% \item ifthen +% \item calc +% \item ifplatform +% \end{list} +% \endgroup +% +% +% \subsection{Installing \pkg{minted}} +% \changes{1.7}{2010/03/16}{Installation instructions added} +% +% If the file |minted.sty| doesn't exist yet, we first have to create this. +% If you're using a system that supports the \app{make} command, then you can simply type the following +% command in the folder where you've extracted the \pkg{minted} package code: +% +% \begin{Verbatim}[gobble=3,commandchars=\\\{\}] +% \$ make +% \end{Verbatim} +% +% Alternatively, you may download this file separately from the +% \href{http://code.google.com/p/minted/downloads/list}{project's homepage}, or create it manually by +% executing the command +% +% \begin{Verbatim}[gobble=3,commandchars=\\\{\}] +% \$ tex minted.ins +% \end{Verbatim} +% +% on the command line. +% +% We now have to install the file so that \TeX{} is able to find them. +% In order to do that, please refer to the +% \href{http://www.tex.ac.uk/cgi-bin/texfaq2html?label=inst-wlcf}{\TeX{} FAQ} on that subject. +% +% % \subsection{Windows} % -% Windows support is sketchy at the moment. +% Windows support is sketchy / untested at the moment. % There are two complications: installation and usage. % % \begin{description} @@ -216,12 +302,12 @@ % \begin{Verbatim}[gobble=7,commandchars=\\\{\}] % @echo off % set PYTHONPATH=C:\mintedbs{}Python26 -% \mintedpcc{}PYTHONPATH\mintedpcc{}\mintedbs{}python.exe \mintedpcc{}PYTHONPATH\mintedpcc\mintedbs{}Scripts\mintedbs{}pygmentize \mintedpcc{}* +% \mintedpcc{}PYTHONPATH\mintedpcc{}\mintedbs{}python.exe \mintedpcc{}PYTHONPATH\mintedpcc{}\mintedbs{}Scripts\mintedbs{}pygmentize \mintedpcc{}* % \end{Verbatim} % \end{description} % -% \section{Basic usage} % +% \section{Basic usage} % % \subsection{Preliminary} % @@ -241,10 +327,45 @@ % The same holds for other processors, such as |pdflatex| or |xelatex|. % % +% \subsection{A minimal complete example} +% \changes{1.7}{2010/03/16}{Minimal working example added} +% +% The following file |minimal.tex| shows the basic usage of \pkg{minted}. +% +% \begin{VerbatimOut}[gobble=1]{minted.doc.out} +% \documentclass{article} +% +% \usepackage{minted} +% +% \begin{document} +% \begin{minted}{c} +% int main() { +% printf("hello, world"); +% return 0; +% } +% \end{minted} +% \end{document} +% \end{VerbatimOut} +% \inputminted[gobble=2,frame=lines]{latex}{minted.doc.out} +% +% By compiling the source file like this: +% +% \begin{Verbatim}[gobble=3,commandchars=\\\{\}] +% \$ pdflatex -shell-escape minimal +% \end{Verbatim} +% +% we end up with the following output in |minimal.pdf|: +% +% \hfill +% \colorbox{minted@samplebg}{\begin{minipage}{0.6\textwidth} +% \inputminted[firstline=7,lastline=10]{c}{minted.doc.out} +% \end{minipage}} +% \hfill\hfill +% % \subsection{Formatting source code} % % \DescribeEnv{minted} -% Using \pkg{minted} is straightforward. For example, to highlight a Python source code, we might use +% Using \pkg{minted} is straightforward. For example, to highlight a Python source code we might use % the following code snippet (result on the right): % % \begin{example} @@ -258,14 +379,14 @@ % in more detail below. % % \DescribeMacro{\mint} -% For one-line source codes, you can alternatively use a shorthand notation similar to |\verb|: +% For one-line source codes, you can alternatively use a shorthand notation similar to |\verb|:^^A| % % \begin{example} % \mint{python}|import this| % \end{example} % -% The complete syntax is \cmd\mint\oarg{options}\marg{language}/\meta{code}/ -% Where the code delimither |/|, like with |\verb|, can be almost any punctuation character. ^^A| +% The complete syntax is \cmd\mint\oarg{options}\marg{language}|/|\meta{code}|/|, +% where the code delimither |/|, like with |\verb|, can be almost any punctuation character. ^^A| % Again, this command supports a number of options described below. % % \DescribeMacro{\inputminted} @@ -281,9 +402,7 @@ % \DescribeMacro{\usemintedstyle} % To do this, put the following into the prelude of your document: % -% \begin{minted}[gobble=3]{latex} -% \usemintedstyle{name} -% \end{minted} +% \mint[frame=lines]{latex}/\usemintedstyle{name}/ % % To get a list of all available stylesheets, execute the following command on the command line: % @@ -306,7 +425,7 @@ % \end{Verbatim} % % -% \section{Floated listings} +% \section{Floated listings}\label{sec:float} % % \DescribeEnv{listing} % \pkg{minted} provides the |listing| environment to wrap around a source code block. @@ -315,7 +434,7 @@ % as for the |table| and |figure| environments): % \begin{VerbatimOut}[gobble=1]{minted.doc.out} % \begin{listing}[H] -% \mint{cl}/(car (cons 1 2))/ +% \mint{cl}/(car (cons 1 '(2)))/ % \caption{Example of a listing.} % \label{lst:example} % \end{listing} @@ -326,11 +445,11 @@ % % will yield: % -% \begin{samepage} -% \rule{\textwidth}{0.4pt}\\ -% \input{minted.doc.out} -% \ \\\rule{\textwidth}{0.4pt}\\ -% \end{samepage} +% \hfill +% \colorbox{minted@samplebg}{\begin{minipage}{0.6\textwidth} +% \input{minted.doc.out} +% \end{minipage}} +% \hfill\hfill % % \DescribeMacro{\listoflistings} % The |\listoflistings| macro will insert a list of all (floated) listings into the document: @@ -343,19 +462,30 @@ % The string ``Listing'' in a listing's caption can be changed. % To do this, simply redefine the macro |\listingscaption|, e.g.: % -% \mint{latex}/\renewcommand\listingscaption{Program code}/ +% \mint[frame=lines]{latex}/\renewcommand\listingscaption{Program code}/ % % \DescribeMacro{\listoflistingscaption} % Likewise, the caption of the listings list, ``List of listings'' can be changed by redefining % |\listoflistingscaption| like so: % -% \mint{latex}/\renewcommand\listoflistingscaption{List of program codes}/ +% \mint[frame=lines]{latex}/\renewcommand\listoflistingscaption{List of program codes}/ % % % \section{Options} % % -% \subsection{Usage} +% \subsection{Package options} +% +% \DescribeMacro{section} +% \DescribeMacro{chapter} +% To control how \LaTeX{} counts the |listing| floats, you can pass either the +% |section| or |chapter| option when loading the \pkg{minted} package. +% For example, the following will cause listings to be counted per-section: +% +% \mint[frame=lines]{latex}/\usepackage[section]{minted}/ +% +% +% \subsection{Macro option usage} % % All \pkg{minted} highlight commands accept the same set of options. % Options are specified as a comma-separated list of |key=value| pairs. @@ -415,14 +545,16 @@ % % \subsection{Available options} % +% \newcommand\appliesto[1]{\textsf{[For #1 only]}} +% % Following is a full list of available options. % For more detailed option descriptions please refer to the \pkg{fancyvrb} documentation, % except where noted otherwise. % \begin{optionlist} -% \item[baselinestretch (+auto+\textbar dimension)] -% Value to use as for baselinestretch inside the listing (default: +auto+). -% \item[bgcolor (string)] -% Background color of the listing (default: \emph{none}). +% \item[baselinestretch (+auto+\textbar dimension) (+auto+)] +% Value to use as for baselinestretch inside the listing. +% \item[bgcolor (string) (\emph{none})] +% Background color of the listing. % Notice that the value of this option must \emph{not} be a color command. Instead, it must be a color % \emph{name}, given as a string, of a previously-defined color: % @@ -435,34 +567,44 @@ % \end{minted} % \end{example} % -% \item[firstline (integer)] -% First line to be shown (default: +1+). +% \item[firstline (integer) (+1+)] +% The first line to be shown. % All lines before that line are ignored and do not appear in the output. -% \item[firstnumber (+auto+\textbar integer)] -% Line number of the first line (default: +auto+ = 1). -% \item[fontfamily (family name)] -% The font family to use (default: +tt+). +% \item[firstnumber (+auto+\textbar integer) (+auto+ = 1)] +% Line number of the first line. +% \item[fontfamily (family name) (+tt+)] +% The font family to use. % +tt+, +courier+ and +helvetica+ are pre-defined. -% \item[fontseries (series name)] -% The font series to use (default: +auto+ -- the same as the current font). -% \item[fontsize (font size)] -% The size of the font to use (default: +auto+ -- the same as the current font). -% \item[fontshape (font shape)] -% The font shape to use (default: +auto+ -- the same as the current font). -% \item[formatcom (command)] -% A format to execute before printing verbatim text (default: \emph{none}). -% \item[frame (+none+\textbar +leftline+\textbar +topline+\textbar +bottomline+\textbar +lines+\textbar +single+)]: -% The type of frame to put around the source code listing (default: +none+). -% \item[framerule (dimension)] -% Width of the frame (default: +0.4pt+). -% \item[framesep (dimension)] -% Distance between frame and content (default: +\fboxsep+). -% \item[gobble (integer)] -% Remove the first $n$ characters from each input line (default: +0+). -% \item[lastline (integer)] -% Last line to be shown (default: \emph{last line of input}). -% \item[linenos (boolean)] -% Enables line numbers (default +false+). +% \item[fontseries (series name) (+auto+ -- the same as the current font)] +% The font series to use. +% \item[fontsize (font size) (+auto+ -- the same as the current font)] +% The size of the font to use, as a size command, e.g. +\footnotesize+. +% \item[fontshape (font shape) (+auto+ -- the same as the current font)] +% The font shape to use. +% \item[formatcom (command) (\emph{none})] +% A format to execute before printing verbatim text. +% \item[frame (+none+\textbar +leftline+\textbar +topline+\textbar +bottomline+\textbar +lines+\textbar +single+) (+none+)] +% The type of frame to put around the source code listing. +% \item[framerule (dimension) (+0.4pt+)] +% Width of the frame. +% \item[framesep (dimension) (\cmd\fboxsep)] +% Distance between frame and content. +% \item[funcnamehighlighting (boolean) (+true+)] \appliesto{PHP} +% If +true+, highlights built-in function names. +% \item[gobble (integer) (+0+)] +% Remove the first $n$ characters from each input line. +% \item[label (\char`\[string\char`\]string) (\emph{empty})] +% Add a label to the top, the bottom or both of the frames around the code. +% See the \pkg{fancyvrb} documentation for more information and examples. +% \emph{Note:} This does \emph{not} add a +\label+ to the current listing. +% To achieve that, use a floating environment (section \ref{sec:float}) instead. +% \item[labelposition (+none+\textbar +topline+\textbar +bottomline+\textbar +all+) (+topline+, +all+ or \emph{none})] +% Position where to print the label (see above; default: +topline+ if one label is defined, +all+ if two are defined, \emph{none} else). +% See the \pkg{fancyvrb} documentation for more information. +% \item[lastline (integer) (\emph{last line of input})] +% The last line to be shown. +% \item[linenos (boolean) (+false+)] +% Enables line numbers. % In order to customize the display style of line numbers, you need to redefine the +\theFancyVerbLine+ % macro: % @@ -481,37 +623,39 @@ % \end{minted} % \end{example} % -% \item[mathescape (boolean)] -% Enable \LaTeX{} math mode inside comments (default: +false+). +% \item[mathescape (boolean) (+false+)] +% Enable \LaTeX{} math mode inside comments. % Do \emph{not} use spaces inside math mode -- they will be rendered like other full-width verbatim spaces. % Usage as in package \pkg{listings}. -% \item[numberblanklines (boolean)] -% Enables or disables numbering of blank lines (default: +true+). -% \item[numbersep (dimension)] -% Gap between numbers and start of line (default: +12pt+). -% \item[obeytabs (boolean)] -% Treat tabs as tabs instead of converting them to spaces (default: +false+). -% \item[resetmargins (boolean)] -% Resets the left margin inside other environments (default: +false+). -% \item[rulecolor (color command)] -% The color of the frame (default: \emph{black}) -% \item[samepage (boolean)] -% Forces the whole listing to appear on the same page, even if it doesn't fit (default: +false+). -% \item[showspaces (boolean)] -% Enables visible spaces: \verb*/visible spaces/ (default: +false+). -% \item[showtabs (boolean)] -% Enables visible tabs -- only works in combination with +obeytabs+ (default: +false+). -% \item[stepnumber (integer)] -% Interval at which line numbers appear (default: +1+). -% \item[tabsize (integer)] -% The number of spaces a tab is equivalent to if +obeytabs+ is not active (default: +8+). -% \item[texcl (boolean)] -% Enables \LaTeX{} code inside comments (default: +false+). +% \item[numberblanklines (boolean) (+true+)] +% Enables or disables numbering of blank lines. +% \item[numbersep (dimension) (+12pt+)] +% Gap between numbers and start of line. +% \item[obeytabs (boolean) (+false+)] +% Treat tabs as tabs instead of converting them to spaces. +% \item[resetmargins (boolean) (+false+)] +% Resets the left margin inside other environments. +% \item[rulecolor (color command) (\emph{black})] +% The color of the frame. +% \item[samepage (boolean) (+false+)] +% Forces the whole listing to appear on the same page, even if it doesn't fit. +% \item[showspaces (boolean) (+false+)] +% Enables visible spaces: \verb*/visible spaces/. +% \item[showtabs (boolean) (+false+)] +% Enables visible tabs -- only works in combination with +obeytabs+. +% \item[startinline (boolean) (+false+)] \appliesto{PHP} +% Specifies that the code starts in PHP mode, i.e. leading +