summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pythontex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-07-21 21:18:20 +0000
committerKarl Berry <karl@freefriends.org>2016-07-21 21:18:20 +0000
commit24289a6c830263430a9ff06f2dd20d6ec3482079 (patch)
treede97f9224a4eae78a947c52df01eb7d1b63c37b0 /Master/texmf-dist/tex/latex/pythontex
parent75ba721d706ce924641fd8f7715a83809b757812 (diff)
pythontex (21jul16)
git-svn-id: svn://tug.org/texlive/trunk@41746 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/pythontex')
-rw-r--r--Master/texmf-dist/tex/latex/pythontex/pythontex.sty150
1 files changed, 113 insertions, 37 deletions
diff --git a/Master/texmf-dist/tex/latex/pythontex/pythontex.sty b/Master/texmf-dist/tex/latex/pythontex/pythontex.sty
index 8bd9c677422..8331043359b 100644
--- a/Master/texmf-dist/tex/latex/pythontex/pythontex.sty
+++ b/Master/texmf-dist/tex/latex/pythontex/pythontex.sty
@@ -8,7 +8,7 @@
%%
%% This is a generated file.
%%
-%% Copyright (C) 2012-2013 by Geoffrey M. Poore <gpoore@gmail.com>
+%% Copyright (C) 2012-2016 by Geoffrey M. Poore <gpoore@gmail.com>
%% --------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
@@ -20,18 +20,17 @@
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{pythontex}
- [2014/07/17 Version~0.14 ]
+ [2016/07/21 v0.15 execute and typeset Python code and other languages]
\newcommand{\pytx@packagename}{PythonTeX}
-\newcommand{\pytx@packageversion}{0.14}
-\RequirePackage{fancyvrb}
-\RequirePackage{etex}
+\newcommand{\pytx@packageversion}{0.15}
+\RequirePackage{fvextra}
\RequirePackage{etoolbox}
\RequirePackage{xstring}
\RequirePackage{pgfopts}
\RequirePackage{newfloat}
-\RequirePackage{currfile}
-\AtBeginDocument{\@ifpackageloaded{color}{}{\RequirePackage{xcolor}}}
+\@ifpackageloaded{currfile}{}{\RequirePackage{currfile}}
+\AtEndPreamble{\@ifpackageloaded{color}{}{\RequirePackage{xcolor}}}
\def\pytx@families{}
\pgfkeys{/PYTX/pkgopt/usefamily/.estore in=\pytx@families}
\def\pytx@opt@gobble{none}
@@ -171,7 +170,23 @@
\def\pytx@pyglexer{}
\pgfkeys{/PYTX/pkgopt/pyglexer/.code=\def\pytx@pyglexer{#1}}
\def\pytx@pygopt{}
-\pgfkeys{/PYTX/pkgopt/pygopt/.code=\def\pytx@pygopt{#1}}
+\pgfkeys{/PYTX/pkgopt/pygopt/.code=\def\pytx@pygopt{#1}\pgfkeys{/PYTX/gopt/pygopt/.cd, #1}}
+\pgfkeys{/PYTX/gopt/pygopt/.is choice}
+\pgfkeys{/PYTX/gopt/pygopt/texcomments/.code=\relax}
+\pgfkeys{/PYTX/gopt/pygopt/mathescape/.code=\relax}
+\pgfkeys{/PYTX/gopt/pygopt/style/.code=\ifstrempty{#1}{}{\def\pytx@style{#1}}}
+\pgfkeys{/PYTX/lopt/pygopt/.is choice}
+\pgfkeys{/PYTX/lopt/pygopt/name/.code=\def\pytx@tmp@name{#1}}
+\pgfkeys{/PYTX/lopt/pygopt/texcomments/.code=\relax}
+\pgfkeys{/PYTX/lopt/pygopt/mathescape/.code=\relax}
+\pgfkeys{/PYTX/lopt/pygopt/style/.code=\ifstrempty{#1}{}{%
+ \expandafter\def\csname pytx@style@\pytx@tmp@name\endcsname{#1}}}
+\pgfkeys{/PYTX/popt/pygopt/.is choice}
+\pgfkeys{/PYTX/popt/pygopt/name/.code=\def\pytx@tmp@name{#1}}
+\pgfkeys{/PYTX/popt/pygopt/texcomments/.code=\relax}
+\pgfkeys{/PYTX/popt/pygopt/mathescape/.code=\relax}
+\pgfkeys{/PYTX/popt/pygopt/style/.code=\ifstrempty{#1}{}{%
+ \expandafter\def\csname pytx@style@PYG\pytx@tmp@name\endcsname{#1}}}
\def\pytx@fvextfile{-1}
\pgfkeys{/PYTX/pkgopt/fvextfile/.default=25}
\pgfkeys{/PYTX/pkgopt/fvextfile/.code=\IfInteger{#1}{%
@@ -230,22 +245,6 @@
!expandafter!scantokens!expandafter{#1!empty}}%
}%
!endgroup
-\ifx\directlua\pytx@undefined\else
-\def\pytx@SVMCR#1 {%
- \edef\pytx@tmp{\csname #1\endcsname}%
- \pytx@SVMCR@i}
-\long\def\pytx@SVMCR@i#1\endpytx@SVMCR{%
- \expandafter\gdef\pytx@tmp{#1}%
-}
-\fi
-\ifx\directlua\relax\else
-\def\pytx@SVMCR#1 {%
- \edef\pytx@tmp{\csname #1\endcsname}%
- \pytx@SVMCR@i}
-\long\def\pytx@SVMCR@i#1\endpytx@SVMCR{%
- \expandafter\gdef\pytx@tmp{#1}%
-}
-\fi
\DefineVerbatimEnvironment{pytx@Verbatim}{Verbatim}{}
\DefineVerbatimEnvironment{pytx@SaveVerbatim}{SaveVerbatim}{}
\newcommand{\setpythontexcontext}[1]{%
@@ -312,9 +311,17 @@
}
\newbool{pytx@usedpygments}
\AfterEndPreamble{%
- \ifbool{pytx@usedpygments}%
- {\InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxpyg}{}{}}{}%
+ \ifbool{pytx@usedpygments}%
+ {\InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxpyg}{}{}%
+ \ifcsname PYGZsq\endcsname
+ \ifdefstring{\PYGZsq}{\char`\'}{\pytx@patch@PYGZsq}{}%
+ \fi}%
+ {}%
}
+\begingroup
+\catcode`\'=\active
+\gdef\pytx@patch@PYGZsq{\gdef\PYGZsq{'}}
+\endgroup
\AtBeginDocument{%
\makeatletter
\InputIfFileExists{\pytx@outputdir/\pytx@jobname.pytxmcr}{}%
@@ -415,6 +422,17 @@
\setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}}
\let\FVB@SaveVerbatim\pytx@FVB@SaveVerbatim
\let\FVE@SaveVerbatim\pytx@FVE@SaveVerbatim
+\def\pytx@ConfigPygments{%
+ \def\pytx@currentstyle{default}%
+ \ifcsname pytx@style\endcsname
+ \let\pytx@currentstyle\pytx@style
+ \else
+ \ifcsname pytx@style@\pytx@type\endcsname
+ \expandafter\let\expandafter\pytx@currentstyle\csname pytx@style@\pytx@type\endcsname
+ \fi
+ \fi
+ \expandafter\let\expandafter\PYG@style\csname PYG\pytx@currentstyle\endcsname
+ \VerbatimPygments{\PYG}{\PYG@style}}
\def\pytx@stdfile{}
\def\pytx@stdout@warntext{}
\def\pytx@FetchStdoutfile[#1][#2]#3{%
@@ -660,6 +678,7 @@
\def\pytx@InlineShowPyg{%
\begingroup
\pytx@FVSet
+ \pytx@ConfigPygments
\ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
\setcounter{pytx@FancyVerbLineTemp}{\value{FancyVerbLine}}%
\BUseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
@@ -683,6 +702,11 @@
}
\ifbool{pytx@opt@stdout}{}{\let\pytx@InlineAutoprint\@empty}
}
+\def\pytx@InlineAlwaysprint{%
+ \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}%
+ {\DepyFile{p:\pytx@outputdir/\pytx@stdfile.stdout}}%
+ {\textbf{??}%
+ \PackageWarning{\pytx@packagename}{Missing sub content}}}
\def\pytx@InlineMacroprint{%
\edef\pytx@mcr{pytx@MCR@\pytx@type @\pytx@session @\pytx@group @\arabic{\pytx@counter}}%
\ifcsname\pytx@mcr\endcsname
@@ -771,6 +795,20 @@
}%
}%
\let\pytx@MakeInlinecPyg\pytx@MakeInlinecFV
+\newcommand{\pytx@MakeInlinesFV}[1]{%
+ \expandafter\newrobustcmd\expandafter{\csname #1s\endcsname}{%
+ \Depythontex{cmd:#1s:ov:p}%
+ \xdef\pytx@type{#1}%
+ \edef\pytx@cmd{s}%
+ \pytx@SetContext
+ \pytx@SetGroup
+ \let\pytx@InlineShow\@empty
+ \let\pytx@InlineSave\pytx@InlineSaveCode
+ \let\pytx@InlinePrint\pytx@InlineAlwaysprint
+ \pytx@Inline
+ }%
+}%
+\let\pytx@MakeInlinesPyg\pytx@MakeInlinesFV
\newcommand{\pytx@MakeInlineFV}[1]{%
\expandafter\newrobustcmd\expandafter{\csname #1\endcsname}{%
\Depythontex{cmd:#1:ov:p}%
@@ -932,6 +970,7 @@
\setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
\pytx@FVSet
\ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
+ \pytx@ConfigPygments
\ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
\UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
\else
@@ -998,9 +1037,9 @@
}%
{\end{VerbatimOut}%
\xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
- \pytx@EnvAutoprint
\setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
\stepcounter{\pytx@counter}%
+ \pytx@EnvAutoprint
}%
}%
\def\pytx@BeginCodeEnv[#1]{%
@@ -1036,6 +1075,29 @@
\setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
\stepcounter{\pytx@counter}%
}%
+\newcommand{\pytx@MakeSubFV}[1]{%
+ \expandafter\newenvironment{#1sub}{%
+ \VerbatimEnvironment
+ \Depythontex{env:#1sub:om|:p}%
+ \xdef\pytx@type{#1}%
+ \edef\pytx@cmd{sub}%
+ \pytx@SetContext
+ \pytx@SetGroup
+ \begingroup
+ \obeylines
+ \@ifnextchar[{\endgroup\pytx@BeginCodeEnv}{\endgroup\pytx@BeginCodeEnv[]}%
+ }%
+ {\end{VerbatimOut}%
+ \xdef\pytx@stdfile{\pytx@type_\pytx@session_\pytx@group_\arabic{\pytx@counter}}%
+ \setcounter{FancyVerbLine}{\value{pytx@FancyVerbLineTemp}}%
+ \stepcounter{\pytx@counter}%
+ \InputIfFileExists{\pytx@outputdir/\pytx@stdfile.stdout}%
+ {\DepyFile{p:\pytx@outputdir/\pytx@stdfile.stdout}}%
+ {\textbf{??~\pytx@packagename~??}%
+ \PackageWarning{\pytx@packagename}{Non-existent substituted content}}%
+ }%
+}%
+\let\pytx@MakeSubPyg\pytx@MakeSubFV
\newcommand{\pytx@MakeConsFV}[2]{%
\expandafter\newenvironment{#1#2}{%
\VerbatimEnvironment
@@ -1107,6 +1169,7 @@
\setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
\pytx@FVSet
\ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
+ \pytx@ConfigPygments
\ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
\UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
\DepyMacro{c:\pytx@counter @\arabic{\pytx@counter}}%
@@ -1124,9 +1187,10 @@
\pgfkeys{
/PYTX/family/.is family,
/PYTX/family,
+ name/.estore in = \pytx@tmp@name,
prettyprinter/.estore in = \pytx@tmp@pprinter,
pyglexer/.estore in = \pytx@tmp@pyglexer,
- pygopt/.estore in = \pytx@tmp@pygopt,
+ pygopt/.code = \def\pytx@tmp@pygopt{#1}\pgfkeys{/PYTX/lopt/pygopt/.cd, #1},
console/.estore in = \pytx@tmp@console,
default/.style = {prettyprinter=auto, pyglexer=text, pygopt={}, console=false}
}
@@ -1173,14 +1237,16 @@
\IfBeginWith{#2}{PYG}%
{\PackageError{\pytx@packagename}%
{Attempt to create macros with reserved prefix PYG}{}}{}%
- \pgfkeys{/PYTX/family, default, #1}
+ \pgfkeys{/PYTX/family, name=#2, default, #1}
\expandafter\xdef\csname pytx@macroformatter@#2\endcsname{\pytx@tmp@pprinter}
\expandafter\gdef\csname pytx@fvsettings@#2\endcsname{}
\expandafter\xdef\csname pytx@pyglexer@#2\endcsname{\pytx@tmp@pyglexer}
\expandafter\xdef\csname pytx@pygopt@#2\endcsname{\pytx@tmp@pygopt}
\expandafter\xdef\csname pytx@console@#2\endcsname{\pytx@tmp@console}
\pytx@MakeInlinecFV{#2}
+ \pytx@MakeInlinesFV{#2}
\pytx@MakeCodeFV{#2}
+ \pytx@MakeSubFV{#2}
\AtBeginDocument{%
\ifcsstring{pytx@macroformatter@#2}{auto}{%
\ifbool{pytx@opt@pygments}%
@@ -1196,6 +1262,7 @@
{\ifcsstring{pytx@console@#2}{true}%
{\pytx@MakeFamilyPygCons{#2}}{\pytx@MakeFamilyPyg{#2}}}{}%
}%
+ \newcounter{pytx@#2@default@default}%
}
\@onlypreamble\makepythontexfamily
\newcommand{\setpythontexpyglexer}[2][]{%
@@ -1212,14 +1279,15 @@
\@onlypreamble\setpythontexpyglexer
\newcommand{\setpythontexpygopt}[2][]{%
\Depythontex{cmd:setpythontexpygopt:om:n}%
- \ifstrempty{#1}{\def\pytx@pygopt{#2}}{%
- \ifcsname pytx@pygopt@#1\endcsname
+ \ifstrempty{#1}%
+ {\def\pytx@pygopt{#2}\pgfkeys{/PYTX/gopt/pygopt/.cd, #2}}%
+ {\ifcsname pytx@pygopt@#1\endcsname
\expandafter\xdef\csname pytx@pygopt@#1\endcsname{#2}%
- \else
+ \pgfkeys{/PYTX/lopt/pygopt/.cd, name=#1, #2}
+ \else
\PackageError{\pytx@packagename}%
- {Cannot modify Pygments options for a non-existent family}{}%
- \fi
- }%
+ {Cannot modify Pygments options for a non-existent family}{}%
+ \fi}%
}
\@onlypreamble\setpythontexpygopt
\newcommand{\setpythontexprettyprinter}[2][]{%
@@ -1252,6 +1320,10 @@
\ifstrequal{#1}{jl}{\makepythontexfamily[pyglexer=julia]{jl}}{}%
\ifstrequal{#1}{matlab}{\makepythontexfamily[pyglexer=matlab]{matlab}}{}%
\ifstrequal{#1}{octave}{\makepythontexfamily[pyglexer=octave]{octave}}{}%
+ \ifstrequal{#1}{bash}{\makepythontexfamily[pyglexer=bash]{bash}}{}%
+ \ifstrequal{#1}{sage}{\makepythontexfamily[pyglexer=sage]{sage}}{}%
+ \ifstrequal{#1}{rust}{\makepythontexfamily[pyglexer=rust]{rust}}{}%
+ \ifstrequal{#1}{rs}{\makepythontexfamily[pyglexer=rust]{rs}}{}%
}
\expandafter\docsvlist\expandafter{\pytx@families}
\newbool{pytx@listingenv}
@@ -1359,6 +1431,7 @@
\setcounter{FancyVerbLine}{\value{\pytx@linecount}}%
\pytx@FVSet
\ifdefstring{\pytx@fvopttmp}{}{}{\expandafter\fvset\expandafter{\pytx@fvopttmp}}%
+ \pytx@ConfigPygments
\ifcsname FV@SV@\pytx@counter @\arabic{\pytx@counter}\endcsname
\UseVerbatim{\pytx@counter @\arabic{\pytx@counter}}%
\else
@@ -1439,6 +1512,7 @@
\begingroup
\pytx@FVSet
\fvset{firstnumber=auto}%
+ \pytx@ConfigPygments
\ifcsname FV@SV@pytx@\pytx@type @\pytx@session @\pytx@group
@\arabic{\pytx@counter}\endcsname
\UseVerbatim[##1]{pytx@\pytx@type @\pytx@session @\pytx@group
@@ -1463,8 +1537,10 @@
}%
\newcommand{\setpygmentspygopt}[2][]{%
\Depythontex{cmd:setpygmentspygopt:om:n}%
- \ifstrempty{#1}{\def\pytx@pygopt{#2}}{%
- \expandafter\gdef\csname pytx@pygopt@PYG#1\endcsname{#2}}%
+ \ifstrempty{#1}%
+ {\def\pytx@pygopt{#2}\pgfkeys{/PYTX/gopt/pygopt/.cd, #2}}%
+ {\expandafter\gdef\csname pytx@pygopt@PYG#1\endcsname{#2}%
+ \pgfkeys{/PYTX/popt/pygopt/.cd, name=#1, #2}}%
}
\@onlypreamble\setpygmentspygopt
\newcommand{\setpygmentsprettyprinter}[1]{%