%%
%% 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-2020 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}
  [2020/10/03 v2.1 Embed node trees into a LaTeX document]
\RequirePackage{xcolor,mdframed,expl3,xparse,fontspec}
\input{nodetree}
\RequirePackage{kvoptions}
\SetupKeyvalOptions{
  family=NTE,
  prefix=NTEK@
}
\directlua{
  nodetree = require('nodetree')
  nodetree.check_shell_escape()
}
\define@key{NTE}{callback}[]{\NodetreeSetOption[callback]{#1}}
\DeclareStringOption[1]{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}
\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][]{
  \setkeys{NTE}{#1}
  \NTE@colors
  \begin{mdframed}[
    linecolor=black,
    backgroundcolor=NTEbackground,
    fontcolor=NTEfont,
  ]%
  \NTE@fonts
}{
  \end{mdframed}%
}
\NewDocumentEnvironment { NodetreeEmbedEnv } { O{} +b } {
  \setkeys{NTE}{#1}
  \ifNTEK@showmarkup
    \noindent
    \texttt{\detokenize{#2}}
  \else
  \fi
  \NTE@colors
  \begin{NodetreeEmbedView}
    \directlua{
      nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
    }
  \end{NodetreeEmbedView}
}{}

\NewDocumentCommand { \NodetreeEmbedCmd } { O{} +v } {
  \setkeys{NTE}{#1}
  \ifNTEK@showmarkup
    \noindent
    \texttt{#2}
  \else
  \fi
  \NTE@colors
  \begin{NodetreeEmbedView}
    \directlua{
      nodetree.compile_include('\luaescapestring{\unexpanded{#2}}')
    }
  \end{NodetreeEmbedView}
}
\newcommand{\NodetreeEmbedInput}[2][]{
  \setkeys{NTE}{#1}
  \begin{NodetreeEmbedView}
  \input{#2.nttex}
  \end{NodetreeEmbedView}
}
\let\nodetreeterminalemulator\NodetreeEmbedInput
\endinput
%%
%% End of file `nodetree-embed.sty'.
