summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/lualatex/pyluatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-07-14 21:10:34 +0000
committerKarl Berry <karl@freefriends.org>2021-07-14 21:10:34 +0000
commit4afc0e03308d532d963e3fad3bbf4be9500276e7 (patch)
treecb819a8887384a9ff3bbe8379d47245bd886168b /Master/texmf-dist/tex/lualatex/pyluatex
parentb235b9fd711ecd18d5db0a03640dc291f5a643cb (diff)
pyluatex (14jul21)
git-svn-id: svn://tug.org/texlive/trunk@59928 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/pyluatex')
-rw-r--r--Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty45
1 files changed, 45 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
new file mode 100644
index 00000000000..752f19d0e76
--- /dev/null
+++ b/Master/texmf-dist/tex/lualatex/pyluatex/pyluatex.sty
@@ -0,0 +1,45 @@
+%% Copyright 2021 Tobias Enderle
+%%
+%% This work may be distributed and/or modified under the
+%% conditions of the LaTeX Project Public License, either version 1.3
+%% of this license or (at your option) any later version.
+%% The latest version of this license is in
+%% http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of LaTeX
+%% version 2005/12/01 or later.
+
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{pyluatex}[2021/07/14 v0.1.2 Execute Python code on the fly]
+
+\RequirePackage{expl3}
+\ExplSyntaxOn
+\sys_if_engine_luatex:TF{}{%
+\PackageError{PyLuaTeX}{LuaTeX~is~required}{}%
+}
+\sys_if_shell_unrestricted:TF{}{%
+\PackageError{PyLuaTeX}{Shell~escape~required~(add~-shell-escape~option)}{}%
+}
+\ExplSyntaxOff
+
+\directlua{require("pyluatex")}
+
+\RequirePackage{kvoptions}
+\DeclareStringOption[python3]{executable}
+\DeclareVoidOption{verbose}{\directlua{pyluatex.verbose = true}}
+\ProcessKeyvalOptions*
+
+\directlua{pyluatex.start([==[\pyluatex@executable]==])}
+
+\newenvironment{python}{\directlua{pyluatex.record_env()}}{}
+
+\newcommand*{\py}[1]{%
+\directlua{pyluatex.execute([==[print(str(#1), end='')]==], true)}%
+}
+
+\newcommand*{\pyc}[1]{\directlua{pyluatex.execute([==[#1]==], true)}}
+
+\newcommand*{\pysession}[1]{\directlua{pyluatex.session = [==[#1]==]}}
+
+\newcommand*{\pyfile}[1]{\directlua{pyluatex.run_file([==[#1]==])}}
+
+\endinput