-
Notifications
You must be signed in to change notification settings - Fork 2
/
nodetree-embed.sty
195 lines (194 loc) · 5.95 KB
/
nodetree-embed.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
%%
%% This is file `nodetree-embed.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% nodetree.dtx (with options: `packageembed')
%%
%% This is a generated file.
%%
%% Copyright (C) 2016-2024 by Josef Friedrich <[email protected]>
%% ----------------------------------------------------------------------
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, either version 1.3c 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.3c or later is part of all distributions of LaTeX
%% version 2008/05/05 or later.
%%
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{nodetree-embed}
[2024/09/17 v2.4.0 Embed node trees into a LaTeX document]
\RequirePackage{xcolor,mdframed,expl3,xparse,fontspec}
\input{nodetree}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
family=NTE,
prefix=NTEK@
}
\define@key{NTE}{callback}[]{\NodetreeSetOption[callback]{#1}}
\DeclareStringOption[0]{verbosity}
\define@key{NTE}{verbosity}[]{\NodetreeSetOption[verbosity]{#1}}
\DeclareStringOption[colored]{color}
\define@key{NTE}{color}[]{\NodetreeSetOption[color]{#1}}
\DeclareStringOption[1]{unit}
\define@key{NTE}{unit}[]{\NodetreeSetOption[unit]{#1}}
\DeclareStringOption[1]{decimalplaces}
\define@key{NTE}{decimalplaces}[]{\NodetreeSetOption[decimalplaces]{#1}}
\DeclareStringOption[monokaisoda]{theme}
\DeclareStringOption[dark]{thememode}
\DeclareStringOption[Ubuntu Mono]{font}
\DeclareStringOption[\footnotesize]{fontsize}
\DeclareStringOption[1]{firstline}
\define@key{NTE}{firstline}[]{\NodetreeSetOption[firstline]{#1}}
\DeclareStringOption[-1]{lastline}
\define@key{NTE}{lastline}[]{\NodetreeSetOption[lastline]{#1}}
\DeclareBoolOption{showmarkup}
\ProcessKeyvalOptions{NTE}
\ExplSyntaxOn
\def\NTE@colors{
\str_case_e:nn{\NTEK@theme}{
{bwdark}{
\definecolor{NTEblack}{gray}{0}
\definecolor{NTEred}{gray}{1}
\definecolor{NTEgreen}{gray}{1}
\definecolor{NTEyellow}{gray}{1}
\definecolor{NTEblue}{gray}{1}
\definecolor{NTEmagenta}{gray}{1}
\definecolor{NTEcyan}{gray}{1}
\definecolor{NTEwhite}{gray}{1}
\definecolor{NTEblackbright}{gray}{0}
\definecolor{NTEredbright}{gray}{1}
\definecolor{NTEgreenbright}{gray}{1}
\definecolor{NTEyellowbright}{gray}{1}
\definecolor{NTEbluebright}{gray}{1}
\definecolor{NTEmagentabright}{gray}{1}
\definecolor{NTEcyanbright}{gray}{1}
\definecolor{NTEwhitebright}{gray}{1}
}
{bwlight}{
\definecolor{NTEblack}{gray}{0}
\definecolor{NTEred}{gray}{0}
\definecolor{NTEgreen}{gray}{0}
\definecolor{NTEyellow}{gray}{0}
\definecolor{NTEblue}{gray}{0}
\definecolor{NTEmagenta}{gray}{0}
\definecolor{NTEcyan}{gray}{0}
\definecolor{NTEwhite}{gray}{1}
\definecolor{NTEblackbright}{gray}{0}
\definecolor{NTEredbright}{gray}{0}
\definecolor{NTEgreenbright}{gray}{0}
\definecolor{NTEyellowbright}{gray}{0}
\definecolor{NTEbluebright}{gray}{0}
\definecolor{NTEmagentabright}{gray}{0}
\definecolor{NTEcyanbright}{gray}{0}
\definecolor{NTEwhitebright}{gray}{1}
}
{monokaisoda}{
\definecolor{NTEblack}{HTML}{1a1a1a}
\definecolor{NTEred}{HTML}{f4005f}
\definecolor{NTEgreen}{HTML}{98e024}
\definecolor{NTEyellow}{HTML}{fa8419}
\definecolor{NTEblue}{HTML}{9d65ff}
\definecolor{NTEmagenta}{HTML}{f4005f}
\definecolor{NTEcyan}{HTML}{58d1eb}
\definecolor{NTEwhite}{HTML}{c4c5b5}
\definecolor{NTEblackbright}{HTML}{625e4c}
\definecolor{NTEredbright}{HTML}{f4005f}
\definecolor{NTEgreenbright}{HTML}{98e024}
\definecolor{NTEyellowbright}{HTML}{e0d561}
\definecolor{NTEbluebright}{HTML}{9d65ff}
\definecolor{NTEmagentabright}{HTML}{f4005f}
\definecolor{NTEcyanbright}{HTML}{58d1eb}
\definecolor{NTEwhitebright}{HTML}{f6f6ef}
}
}
\str_case_e:nn{\NTEK@thememode}{
{dark}{
\definecolor{NTEbackground}{named}{NTEblack}
\definecolor{NTEfont}{named}{NTEwhitebright}
}
{light}{
\definecolor{NTEbackground}{named}{NTEwhitebright}
\definecolor{NTEfont}{named}{NTEblack}
}
}
}
\ExplSyntaxOff
\def\NTE@fonts{
\bfseries%
\NTEK@fontsize%
\setmonofont{\NTEK@font}%
\ttfamily%
\setlength{\parindent}{0pt}%
\setlength{\parskip}{-0.9pt}%
}
\providecommand{\NodetreeSet}[1]{%
\setkeys{NTE}{#1}%
}
\newenvironment{NodetreeEmbedView}[1][]{
\directlua{nodetree.push_options()}
\setkeys{NTE}{#1}
\NTE@colors
\begin{mdframed}[
linecolor=black,
backgroundcolor=NTEbackground,
fontcolor=NTEfont,
]%
\NTE@fonts
}{
\end{mdframed}%
\directlua{nodetree.pop_options()}%
}
\NewDocumentEnvironment { NodetreeEmbedEnv } { O{} +b } {
\directlua{
nodetree.check_shell_escape('NodetreeEmbedEnv', false)
nodetree.push_options()
}
\setkeys{NTE}{#1}
\ifNTEK@showmarkup
\noindent
\texttt{\detokenize{#2}}
\fi
\NTE@colors
\begin{NodetreeEmbedView}
\directlua{
nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
}
\end{NodetreeEmbedView}
\directlua{nodetree.pop_options()}
}{}
\NewDocumentCommand { \NodetreeEmbedCmd } { O{} +v } {
\directlua{
nodetree.check_shell_escape('\string\\NodetreeEmbedCmd', true)
nodetree.push_options()
}
\setkeys{NTE}{#1}
\ifNTEK@showmarkup
\noindent
\texttt{#2}
\fi
\NTE@colors
\begin{NodetreeEmbedView}
\directlua{
nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
}
\end{NodetreeEmbedView}
\directlua{nodetree.pop_options()}
}
\newcommand{\NodetreeEmbedInput}[2][]{
\directlua{nodetree.push_options()}
\setkeys{NTE}{#1}
\begin{NodetreeEmbedView}
\directlua{nodetree.input('#2.nttex')}
\end{NodetreeEmbedView}
\directlua{nodetree.pop_options()}
}
\let\nodetreeterminalemulator\NodetreeEmbedInput
\endinput
%%
%% End of file `nodetree-embed.sty'.