%%
%% 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 <josef@friedrich.rocks>
%% ----------------------------------------------------------------------
%% 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'.
