diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex')
-rw-r--r-- | Master/texmf-dist/tex/latex/pythonhighlight/pythonhighlight.sty | 38 |
1 files changed, 29 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/latex/pythonhighlight/pythonhighlight.sty b/Master/texmf-dist/tex/latex/pythonhighlight/pythonhighlight.sty index 88561ed326f..0c772a1e261 100644 --- a/Master/texmf-dist/tex/latex/pythonhighlight/pythonhighlight.sty +++ b/Master/texmf-dist/tex/latex/pythonhighlight/pythonhighlight.sty @@ -1,11 +1,13 @@ -% Copyright 2009--2017 by Olivier Verdier +% Copyright 2009--2024 by Olivier Verdier % License: see the file LICENSE.rst \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{pythonhighlight}[2017/02/09 python code highlighting; provided by Olivier Verdier <olivier.verdier@gmail.com>] +\UseRawInputEncoding +\ProvidesPackage{pythonhighlight}[2024/03/18 python code highlighting; provided by Olivier Verdier <olivier.verdier@gmail.com>] \RequirePackage{listings} \RequirePackage{xcolor} +\RequirePackage{xparse} \renewcommand*{\lstlistlistingname}{Code Listings} \renewcommand*{\lstlistingname}{Code Listing} @@ -27,7 +29,7 @@ \newcommand*{\pythonprompt}{\textcolor{promptcolour}{{>}{>}{>}}} -\lstdefinestyle{mypython}{ +\lstdefinestyle{pythonhighlight-style}{ %\lstset{ %keepspaces=true, language=python, @@ -40,7 +42,7 @@ showstringspaces=false, alsoletter={1234567890}, otherkeywords={\%, \}, \{, \&, \|}, keywordstyle=\color{keywordcolour}\bfseries, -emph={and,break,class,continue,def,yield,del,elif ,else,% +emph={and,as,async,await,break,class,continue,def,yield,del,elif ,else,% except,exec,finally,for,from,global,if,import,in,% lambda,not,or,pass,print,raise,return,try,while,assert,with}, emphstyle=\color{blue}\bfseries, @@ -98,12 +100,30 @@ breakindent=.5\textwidth,frame=single,breaklines=true% %} } -\newcommand*{\inputpython}[3]{\lstinputlisting[firstline=#2,lastline=#3,firstnumber=#2,frame=single,breakindent=.5\textwidth,frame=single,breaklines=true,style=mypython]{#1}} +\newcommand*{\inputpython}[3]{\lstinputlisting[firstline=#2,lastline=#3,firstnumber=#2,frame=single,breakindent=.5\textwidth,frame=single,breaklines=true,style=pythonhighlight-style]{#1}} +\NewDocumentCommand\inputpythonfile{moo}{\lstinputlisting[ + firstline=\IfValueTF{#2}{#2}{0}, + % firstnumber=\IfValueTF{#2}{#2}{0}, + lastline=\IfValueTF{#3}{#3}{9999999}, + frame=single, + breakindent=.5\textwidth, + frame=single, + breaklines=true, + style=pythonhighlight-style + ]{#1}} -\lstnewenvironment{python}[1][]{\lstset{style=mypython}}{} +\lstnewenvironment{python}[2][]{% + \lst@TestEOLChar{#2}% + \lstset{style=pythonhighlight-style}% + \lstset{#1}% % has to be in an extra \lstset{} command so that labels work correctly + \csname\@lst @SetFirstNumber\endcsname% +}{% + \let\if@nobreak\iffalse% + \csname\@lst @SaveFirstNumber\endcsname% +} -\lstdefinestyle{mypythoninline}{ -style=mypython,% +\lstdefinestyle{pythonhighlight-inline-style}{ + style=pythonhighlight-style,% basicstyle=\ttfamily,% keywordstyle=\color{keywordcolour},% emphstyle={[7]\color{keywordcolour}},% @@ -135,5 +155,5 @@ literate=*% %% emphstyle=\color{blue},% } -\newcommand*{\pyth}{\lstinline[style=mypythoninline]} +\newcommand*{\pyth}{\lstinline[style=pythonhighlight-inline-style]} |