aboutsummaryrefslogtreecommitdiff
path: root/exercisesheets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'exercisesheets.sty')
-rw-r--r--exercisesheets.sty45
1 files changed, 45 insertions, 0 deletions
diff --git a/exercisesheets.sty b/exercisesheets.sty
index 0024d76..9492cb9 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -1205,3 +1205,48 @@
\newcommand{\samplehide}[1]{%
\ifbool{exsh@samplesolutions}{}{#1}%
}
+
+
+\ifluatex
+\usepackage{luacode}
+\begingroup
+\catcode`!=0
+\catcode`\@=11
+\catcode`\_=12
+\catcode`\{=12 %set those to the same value (11/12) as below!
+\catcode`\}=12 %
+\catcode`<=1
+\catcode`>=2
+\catcode`\~=11
+\catcode`\\=11
+%% Exoanded, when \catcode`\^^M=12 holds
+!global!long!def!@start@Lexercise@Helper#1\end{Lexercise}< %
+ !directlua<exsh_cur_exercise=exercise ({#1})> %
+ !endgroup!end<Lexercise>!par %
+>
+!endgroup
+\def\startLexercise{
+\begingroup
+\catcode`!=12
+\catcode`\$=12
+\catcode`\#=12
+\catcode`\_=12
+\catcode`\^=12
+\catcode`\&=12
+\catcode`\|=12
+\catcode`\{=12 %set those to the same value (11/12) as above!
+\catcode`\}=12 %
+\catcode`\~=12
+\catcode`\@=11
+\catcode`\%=12
+\catcode`\^^I=12
+\catcode`\^^J=12\catcode`\^^M=12\catcode`\\=11\endlinechar-1\@start@Lexercise@Helper}
+
+\newenvironment{Lexercise}{%
+ \startLexercise%
+}{%
+ \directlua{tex.print(exsh_cur_exercise)}
+}
+
+\directlua{dofile("lexercise.lua")}
+\fi