%%%==============================================================================
% WinEdt pragmas
% !Mode:: "TeX:EN"
% Default Compile engines:
% !TEX program = pdflatex
% !PDFTeXify ext =  --enable-etex  --restrict-write18
% !PDFLaTeX ext  =  --enable-etex  --restrict-write18
% !BIB program = biber
%%%==============================================================================
%% Copyright 2026-present by Alceu Frigeri
%%
%% This work may be distributed and/or modified under the conditions of
%%
%% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
%%   version 1.3c (or later), and/or
%% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
%%   version 3 (or later)
%%
%% This work has the LPPL maintenance status *maintained*.
%%
%% The Current Maintainer of this work is Alceu Frigeri
%%
%% This is version {1.0} {2026/11/27}
%%
%% The list of files that compose this work can be found in the README.md file at
%% https://ctan.org/pkg/codehighlight
%%
%%%==============================================================================
\documentclass[10pt]{article}
\RequirePackage[verbose,a4paper,marginparwidth=27.5mm,top=2.5cm,bottom=1.5cm,hmargin={40mm,20mm},marginparsep=2.5mm,columnsep=10mm,asymmetric]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[infograb,silence]{codedescribe}
\RequirePackage[inline]{enumitem}
\SetEnumitemKey{miditemsep}{parsep=0ex,itemsep=0.4ex}

\usepackage { longtable,multirow,hhline}

\usepackage{codeverbatim}
\usepackage{codehighlight}

\usepackage{newfloat}

\newcodekey{codehl}
  {
    codeprefix={},
    resultprefix={},
    letter={_ : -},
    texcs=[2]{hlKeysetDef,hlSettings,cvNewEnvironment,hlDisplayV,hlLangDef,hlHLsetDef,
    hlBasefmtDef,hlSettingsDef,cvSVerbNew,cvSVerbSet,cvSVerbOn,cvSVerbOff,cvHideSpc,cvRetokenEnvNewCommand,codeverb_new_environment:nnnnn},
    texcs=[3]{ExplSyntaxOn,ExplSyntaxOff},
    emph=[1]{nestable,tagged,based,on,keywd,string,in,on,case,sensitive,
    alphanumeric,digits,oletter,identifier,area,comment,line,at,discard,
    active,delimited,replace,suppress,emph,info,note,
    gobble,inline,add,endmark,base,format,show,spaces,text,width,wrap,indent,
    background,numbers,sep,rule,width,color,frame,left,right,top,bottom,
    hl,set,registered,defined,settings,basefmt,hlset,keyset,lang,show,all
    settings,language,drop,first,other }  
  } 

\ExplSyntaxOn
\NewDocumentCommand \citepkg { sO{}m } 
  {
    \seq_set_from_clist:Nn \l__codehl_doctmp_seq { #2 }
    \seq_pop_left:NNTF \l__codehl_doctmp_seq
      \l__codehl_doctmpa_tl
      { 
        \emph { `` \l__codehl_doctmpa_tl '' }
        \seq_pop_right:NNTF \l__codehl_doctmp_seq
          \l__codehl_doctmpb_tl
          {
            \seq_map_inline:Nn \l__codehl_doctmp_seq
              {
               , ~ \emph { `` ##1 '' }
              }
            \use:n { ~ } and ~ \emph { `` \l__codehl_doctmpb_tl '' }
          }
          { }
         \use:n { ~ }  from ~ 
      }
      {  }
  
    \bool_if:NTF #1
      { \citetitle { #3 } \, \cite { #3 }  }
      { \tsobj [pkg]  { #3 } \, \cite { #3 } }
  }
\ExplSyntaxOff

\begin{codestore}[demofloat]
  %% This must be declared in the preamble
  \DeclareFloatingEnvironment
    [fileext={lov},listname={List of C code},name={C code},placement=htb]
    {floatenv}
\end{codestore}

\tsexec{demofloat}

\begin{codestore}[demoLoad]
% only in the preamble
\hlLangLoad{ C , php , TeX }
\end{codestore}

\tsexec{demoLoad}[1]


\begin{codestore}[demo00]
% if the file definition were already loaded, the following can be anywhere
\hlSettings
  {
    keywd set = { C }
  }

\cvNewEnvironment[verb tl=\DemoV]{DemoEnv}{}
  {}
  { 
  \hlDisplayV \DemoV 
%  \myShow \DemoV
  }
\end{codestore}

\begin{codestore}[demo00]
\hlSettings
  {
    language = C ,
    keywd set = C
  }
\end{codestore}

\tsexec{demo00}[1]

%\hlLangShow{C}  


%% if needed
\RequirePackage[backend=biber]{biblatex}
\addbibresource{codehighlight.bib}

\RequirePackage[hidelinks,hypertexnames=false]{hyperref}

\begin{document}
\tstitle{
  author={Alceu Frigeri\footnote{\tsfmt{\url{https://github.com/alceu-frigeri/codeverbatim}}}},
  date={\tsdate},
  title={The codehighlight Package\break Version \PkgInfo{codehighlight}{version}}
  }
  

\begin{typesetabstract}
 
This package enables the typesetting of verbatim code with syntax highlight. It allows for customization of all aspects related to syntax highlight, including the definition of what constitute a comment, a string, an identifier, etc. No attempt is made to grab some code in verbatim mode, this package relies on other packages for that, like \citepkg{codeverbatim} (its companion package) or the likes of \citepkg{fancyvrb} or \citepkg{scontents}.
\end{typesetabstract}

\tableofcontents

\newpage
\section{Introduction}

The aim of this package (and its companion \citepkg{codeverbatim}) is to allow the creation of fully customizable verbatim environments. To achieve that, unlike other packages of the kind as \citepkg{fancyvrb}, \citepkg{scontents} or \citepkg{listings}, which have a fixed set of ways to collect/display a verbatim environment, \tsobj[pkg]{codeverbatim,codehighlight}  split the action of grabbing some code in verbatim mode (package, \citepkg{codeverbatim}) from typesetting it with or without syntax highlight (this package \tsobj[pkg]{codehighlight}).

\tsobj[pkg]{codehighlight} offers ways to (syntax) highlight the code grabbed with  \citepkg{codeverbatim}. It's somewhat inspired on the  \citepkg{listings} functionality, allowing the definition of a custom syntax (for code highlight). Unlike \citepkg{listings}, in \tsobj[pkg]{codehighlight} four aspects: (1) syntax definition, (2) keyword's sets, (3) highlight formatting and (4) base formatting, are kept separated, allowing a more flexible setup.
\begin{tsremark}
  Although the two packages are though to be used together, they can be used separately. It's perfectly possible to use \tsobj[pkg]{codeverbatim} together with \citepkg{listings} package, or  \citepkg{codehighlight} with other verbatim package, like \citepkg{fancyvrb} (using the macros \tsobj{\SaveVerb,\UseVerb}) or \citepkg{scontents} (redefining the \tsobj[env]{verbatimsc} environment).
\end{tsremark}
Lastly, this package is fully written in \citepkg{expl3}, but given that one might want to use it in a \LaTeXe{} context (either at package or document level), all public commands have a \LaTeXe{} alias, and, for simplicity, they are listed together.



\section{The codehighlight Package}\label{pkg:codehl}
After capturing some code in verbatim mode (for instance, using the package \citepkg{codeverbatim}) this provides commands to typeset them, highlighting some structures/keywords in the process.
\begin{tsremark}
  This is not a pretty print or formatter package. That for, a full parser would be necessary, which is way beyond the scope of this package.
\end{tsremark}
The specification of how and what will be highlighted is split in:
\begin{itemize}
  \item Language syntax (\tsobj[marg]{lang} from \ref{codehl:syntax:lang}), which defines how the code scanner can recognize elements as identifiers, comments, strings, etc. and associate those recognized elements with a formatting class.
  \item Keywords sets (\tsobj[marg]{kewy-set} from \ref{codehl:syntax:keywd}), which just defines sets of keywords (list), and associate them with a formatting class.
  \item Highlight sets (\tsobj[marg]{hlset-set} from \ref{codehl:syntax:hlset}), which maps a formatting class with a formatting code itself.
  \item Base format sets (\tsobj[marg]{basefmt-set} from \ref{codehl:syntax:baseformat}) which sets the general formatting of the code to be displayed, like frame, background, etc.
\end{itemize}

All those aspects are decouple from each other, for instance one can use different sets of keywords with a given language, or have alternative highlight sets and use one or the other as desired.

As mentioned, the following display commands assumes the code was captured verbatim (for instance with \citepkg{codeverbatim}) and stored in an \citepkg{expl3} token list variable. The user is free to capture it in other ways, or process the code of said variable, in which case a few remarks are important:
\begin{itemize}
  \item The end of line, line break mark is \tsfmt[verb]{\^{}\^{}J} (following the \citepkg{expl3} convention (see command \tsobj{\tl_retokenize:n} in \citepkg*[Reassigning category codes]{expl3}).
  \item No character with the following category codes should appear (of course, the characters themselves can appear, just not with the following category codes):
      
      
\begin{center}
\begin{tabular}{rlcrlc}
catcode & name & usually & catcode & name & usually \\
  \hline
     0 &  escape &   \tsverb[verb]{\ } &
     6 &  parameter &   \tsfmt[verb]{\#} \\

     1 &  begin group &   \tsfmt[verb]{\}} &
     7 &  math superscript &   \tsfmt[verb]{\^{}}  \\
     
     2 &  end group &   \tsfmt[verb]{\{}  &
     8 &  math subscript &   \tsfmt[verb]{\_{}}  \\

     3 &  math toggle &   \tsfmt[verb]{\$} &
     14 &  comment &   \tsfmt[verb]{\%{}} \\

     4 &  alignment &   \tsfmt[verb]{\&} \\
  \hline
\end{tabular}
\end{center}
        
\end{itemize}

\subsection{UTF8 and other active characters}
Characters with character code greater then 127 are assumed to be active \tsobj{utf8} characters and ``aren't touched'': the scanning routines will keep then as is, together, letting \LaTeXe{} process them in the usual way.

On the other hand, characters with a character code below 128 are assumed to be non-active. In general, it's advisable to handle them before calling any of the display commands, either by turning them off before grabbing the code, or setting a custom environment with \tsobj[pkg]{codeverbatim} (see sections \citepkg[{New Verbatim Environment}
, {Characters Category Code and Common Keys}]{codeverbatim}), to turn them off or processing the grabbed code before displaying it.

The main problem that might arise from an active character (category code 13) with a character code below 128 is that the highlighting routines, besides the formatting code itself, will insert lots of breaking commands (e.g. \tsobj{\penalty 0 \relax} commands) that, most likely, won't work well with whatever code was associated with the active character, most likely triggering low level kernel errors.

Of course, if the code associated with a given active character doesn't depends on \emph{what is around}, it is safe to preserve them as active characters.

\subsection{Display Settings}\label{codehl:settings}
\begin{codedescribe}[code]{ \hlSettings, \codehl_settings:n}
\begin{codesyntax}%
\tsmacro{\hlSettings}{keys}
\tsmacro{\codehl_settings:n}{keys}
\end{codesyntax}
These will set (or change) the many display aspects. Note that, this is when the scan functions and variables associated with a language, keywords and highlight sets are created (see \ref{codehl:building:defs}).

\end{codedescribe}

\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
  \describe{language}
    {This will select the given language as the active one (See \ref{codehl:syntax:lang}). If set to an empty value (\tsobj[key]{language =} \tsobj[value]{\{\}})  no language specific patterns will be recognized. }
  \describe{hl set}
    {This will select the given highlight set as the active one. See \ref{codehl:syntax:hlset}. If set to an empty value (\tsobj[key]{hl set =} \tsobj[value]{\{\}})  no syntax highlight will ensue. }
  \describe{keywd set}
    {This will select the given keyword set as the active one. See \ref{codehl:syntax:keywd}. If set to an empty value (\tsobj[key]{keywd set =} \tsobj[value]{\{\}})  no keyword will be recognized. }
  \describe{base format}
    {This will select the given base format set as the active one. See \ref{codehl:syntax:baseformat}. If set to an empty value (\tsobj[key]{base format =} \tsobj[value]{\{\}})  then \tsobj[value]{std-basefmt} (see \ref{codehl:syntax:baseformat}) will be selected as the base format. }
\begin{tsremark}
  All keys can be set to an empty value, but, if a non empty value is given, and the respective \tsobj[key,or]{language, hl set, keywords set, base format} doesn't exist, an error will be raised.
\end{tsremark}    
\begin{tsremark}
  Initially, \tsobj[key]{language,keywd set} are set to empty (no definition), whilst, \tsobj[key]{base format} is set to \tsobj[value]{std-basefmt} and \tsobj[key]{hl set} is set to \tsobj[value]{std-hlset}.
\end{tsremark}    
\end{describelist*}


\begin{codedescribe}[code]{ \hlSettingsDef, \codehl_settings_def:nn }
\begin{codesyntax}%
\tsmacro{\hlSettingsDef}{settings-id,keys}
\tsmacro{\codehl_settings_def:nn}{settings-id,keys}
\end{codesyntax}
This will create a settings set, \tsobj[marg]{settings-id}, and associate with it (for later use) a language \tsobj[marg]{lang}, highlight set \tsobj[marg]{hlset}, keyword set \tsobj[marg]{keyset} and base format set \tsobj[marg]{basefmt}, to be used by \tsobj[code,or]{\hlSettingsSelect,\codehl_settings_select:n}. This is just a helper construct, in case one needs to, repeatedly,  change over a few different setups.
\end{codedescribe}

\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
  \describe{based on language}
    {
      \tsargs[marg]{lang-list}
      
      If set to empty, no language will be associated with \tsobj[marg]{settings-id}. 
      
      If a single value is given, \tsobj[marg]{lang}, it will test if \tsobj[marg]{lang} exists, and associate it with \tsobj[marg]{settings-id}. 
      
      If \tsobj[marg]{lang-list} is indeed a list, a language named \tsobj[marg]{settings-id\_lang} will be defined setting the \tsobj[key]{based on} key (see \ref{codehl:syntax:basedon} and \ref{codehl:syntax:lang}) to that list, and this language, \tsobj[marg]{settings-id\_lang}, will be associated with \tsobj[marg]{settings-id}. }
  \describe{based on hl set}
    {
      \tsargs[marg]{hlset-list}
      
      If set to empty, no highlight set will be associated with \tsobj[marg]{settings-id}. 
      
      If a single value is given, \tsobj[marg]{hlset}, it will test if \tsobj[marg]{hlset} exists, and associate it with \tsobj[marg]{settings-id}. 
      
      If \tsobj[marg]{hlset-list} is indeed a list, a highlight set named \tsobj[marg]{settings-id\_hlset} will be defined setting the \tsobj[key]{based on} key (see \ref{codehl:syntax:basedon} and \ref{codehl:syntax:hlset}) to that list, and this highlight set, \tsobj[marg]{settings-id\_hlset}, will be associated with \tsobj[marg]{settings-id}.  }
  \describe{based on keywd set}
    {
      \tsargs[marg]{keyset-list}
      
      If set to empty, no keyword set will be associated with \tsobj[marg]{settings-id}. 
      
      If a single value is given, \tsobj[marg]{keyset}, it will test if \tsobj[marg]{keyset} exists, and associate it with \tsobj[marg]{settings-id}. 
      
      If \tsobj[marg]{keyset-list} is indeed a list, a keyword set named \tsobj[marg]{settings-id\_keyset} will be defined setting the \tsobj[key]{based on} key (see \ref{codehl:syntax:basedon} and \ref{codehl:syntax:keywd}) to that list, and this keyword set, \tsobj[marg]{settings-id\_keyset}, will be associated with \tsobj[marg]{settings-id}.  }
  \describe{based on base format}
    {
      \tsargs[marg]{basefmt-list}
      
      If set to empty, \tsobj[marg]{std-basefmt} set will be associated with \tsobj[marg]{settings-id}. 
      
      If a single value is given, \tsobj[marg]{basefmt}, it will test if \tsobj[marg]{basefmt} exists, and associate it with \tsobj[marg]{settings-id}. 
      
      If \tsobj[marg]{basefmt-list} is indeed a list, a base format set named \tsobj[marg]{settings-id\_basefmt} will be defined setting the \tsobj[key]{based on} key (see \ref{codehl:syntax:basedon} and \ref{codehl:syntax:baseformat}) to that list, and this base format set, \tsobj[marg]{settings-id\_basefmt}, will be associated with \tsobj[marg]{settings-id}.  }
      
\end{describelist*}

\begin{codedescribe}[code]{ \hlSettingsSelect,\codehl_settings_select:n}
\begin{codesyntax}%
\tsmacro{\hlSettingsSelect}{settings-id}
\tsmacro{\codehl_settings_select:n}{settings-id}
\end{codesyntax}
This will call \tsobj{\codehl_settings:n} with the \tsobj[marg]{language,hl set, keywd set, base format} associated with \tsobj[marg]{settings-id}.
\end{codedescribe}



\subsection{Display commands}\label{codehl:display}
\begin{codedescribe}[code,force margin,variants=list]{ \hlDisplay ,  \hlDisplayV , \codehl_display:nn { no }  }
\begin{codesyntax}%
\tsmacro{\hlDisplay}[keys]{code}
\tsmacro{\hlDisplayV}[keys]{tl-var}
\tsmacro{\codehl_display:nn}{keys,code}
\tsmacro{\codehl_display:no}{keys,tl-var}
\end{codesyntax}
These will display (typeset) the contents of \tsobj[marg,or]{code,tl-var} (an \citepkg{expl3} token list variable) accordingly with the active language, highlight set, etc.
\begin{tsremark}[\color{red}Note:]
  The highlight routines expect \tsobj[marg]{code} to be terminated by \tsfmt[verb]{\^{}\^{}J }, an end-of-line marker, as used by the command \tsobj{\tl_retokenize:n} see \citepkg[Reassigning category code]{expl3}. A quark loop will ensue otherwise.
\end{tsremark}
\begin{tsremark}
  In it's default settings, a verbatim environment or short verbatim command created with \citepkg{codeverbatim}, follow this convention.
\end{tsremark}
\end{codedescribe}

\tsobj[marg]{keys} can be any combination of the keys from \ref{codehl:syntax:baseformat} (except the \tsobj[key]{based on} key) and the following:
\begin{describelist*}{keys}
  \describe{hl set}
    {This will locally extend the active highlight set.  
    The expected syntax is \tsfmt[key]{hl set = \{\tsobj[marg]{hl-keys}\}}, whereas \tsobj[marg]{hl-keys} can be any combination of keys from \ref{codehl:syntax:hlset} (except the \tsobj[key]{based on} key).
    }
    \begin{tsremark}
      This can only be used if a valid \tsobj[key]{hl set} was selected with \tsobj[code,or]{\hlSettings,\codehl_settings:n}.
    \end{tsremark}
  \describe{keywd set}
    {This will locally extend the keywords set. 
    The expected syntax is \tsfmt[key]{keywd set = \{\tsobj[marg]{keywd-keys}\}}, whereas \tsobj[marg]{keywd-keys} can be any combination of keys from \ref{codehl:syntax:keywd} (except the \tsobj[key]{based on} key).
    }
    \begin{tsremark}
      This can only be used if a valid \tsobj[key]{keywd set} was selected with \tsobj[code,or]{\hlSettings,\codehl_settings:n}.
    \end{tsremark}
\end{describelist*}

\newpage
\subsection{Language and syntax highlight definitions}\label{codehl:lang:defs}
There are a few main cases to be taken care of:
\begin{itemize}
  \item comments/strings $\rightarrow$ A language \tsobj[marg]{lang} (see \ref{codehl:syntax:lang}) defines the start/end patterns and associated \tsobj[marg]{class}, whilst a highlight set \tsobj[marg]{hlset-set} (see \ref{codehl:syntax:hlset}) associates the related \tsobj[marg]{class} with a format to be used.
      
      For example, when setting a language one can have: \tsverb[key]{comment = {3}{/*}{*/}} which will define a C++ style comment and associate \tsobj[key]{comment} \tsobj[marg]{class} \tsobj[key]{3} with it. The format to be applied will come from a highlight set (see \ref{codehl:syntax:hlset}), like: \tsverb[key]{comment = {3}{\color{blue}}}.
      
\begin{tsremark}
  Comments can be discarded, or made \emph{active}, meaning the comment text will be handled as normal \LaTeXe{} code.
\end{tsremark}

  \item keywords $\rightarrow$ A keyword set, \tsobj[marg]{keyset-set} (see \ref{codehl:syntax:keywd}), associates keywords with a \tsobj[marg]{class}, whilst a highlight set \tsobj[key]{hlset-set} (see \ref{codehl:syntax:hlset}) associates the related \tsobj[marg]{class} with a format to be used.
      
      For example, when setting a keyword set, one can have: \tsverb[key]{keywd = {2}{some,words}} and \tsverb[key]{keywd = {3}{special}}. The format to be applied will come from a highlight set (see \ref{codehl:syntax:hlset}), like: \tsverb[key]{keywd = {2}{\bfseries}} and \tsverb[key]{keywd = {3}{\color{red}}}. That way the words \emph{some} and \emph{words} will appear in bold face, whilst \emph{special} in red.
      
      
  \item identifiers $\rightarrow$ \tsobj[key]{language} (see \ref{codehl:syntax:lang}) defines the delimiter \tsobj[marg]{start-pattern} and associated \tsobj[marg]{id-name}, a \tsobj[marg]{keyset-set} (see \ref{codehl:syntax:keywd}) associates keywords with a \tsobj[marg]{id-name}\tsobj[marg]{class}, and \tsobj[marg]{hlset-set} (see \ref{codehl:syntax:hlset}) associates the related \tsobj[marg]{id-name}\tsobj[marg]{class} with a format to be used.
      
      That's a special case of keywords, for example, when setting a language one can have: \tsverb[key]{identifier = {texcs}{\\}} which will define a \LaTeXe{} style identifier, associated with the \tsobj[marg]{id-name} \tsobj[value]{texcs}. 
      
      Then, when setting a keyword set, one can have: \tsverb[key]{texcs = {2}{cmdA,cmdB}} and \tsverb[key]{texcs = {3}{cmdC}}, and, finally, the format to be applied will come from a highlight set (see \ref{codehl:syntax:hlset}), like: \tsverb[key]{texcs = {2}{\bfseries}} and \tsverb[key]{texcs = {3}{\bfseries\color{blue}}}. That way the commands \tsobj{\cmdA} and \tsobj{\cmdB} will appear in bold face, whilst \tsobj{\cmdC} in blue.
      
  \item tagged area keywords $\rightarrow$ \tsobj[key]{language} (see \ref{codehl:syntax:lang}). When inside a \tsobj[key]{tagged area},  keywords associated with a \tsobj[key]{keywd} key, aren't recognized, but only those associated with \tsobj[key]{tag-name}. For instance \tsverb[key]{ tagged  area =  { html } { < } { > } { non ~ tagged }} (\tsobj[value]{html} tag definition). Then, when setting a keyword set, one can have: \tsverb[key]{html = {2}{keywdA,keywdB}} and \tsverb[key]{html = {3}{keywdC}}, and, finally, the format to be applied will come from a highlight set (see \ref{codehl:syntax:hlset}), like: \tsverb[key]{html = {2}{\bfseries}} and \tsverb[key]{html = {3}{\bfseries\color{blue}}}. That way the keywords \tsobj{keywdA,keywdB} will appear in bold face, whilst \tsobj{keywdC} in blue, IF inside the tagged area.
\end{itemize}

\begin{tsremark}
  Note that, even though, all these aspects are related, they all (language sets, highlight sets, keyword sets and base format set) are decouple at definition time. Only when effectively displaying a given code that they will be ``bring together'', this allows (for instance) to have separated sets of keywords for a given language, and using one or another as needed.
\end{tsremark}

\subsection{Based on syntax and class remapping}\label{codehl:syntax:basedon}
In the following sections, a common key is \tsobj[key]{based on}, whose general syntax is: 

\tsobj[key]{based on} = \tsfmt[value]{ \{ \tsobj[meta]{base-set$_1$} , \tsobj[meta]{base-set$_2$} \dots \}}

And, \tsobj[meta]{base-set$_i$} can be any combination of:
\begin{describelist*}{value}
  \describe{\tsobj[meta]{base}}
    { 
      The \tsobj[marg]{base} will be inherited, as is. No class re-mapping.  
    }
  \describe{R[int]\tsobj[meta]{base}}
    { The \tsobj[marg]{base} classes will be re-mapped, adding \tsmeta{int} to all sub-\tsmeta{base} classes. }
  \describe{S[int]\tsobj[meta]{base}}
    { The \tsobj[marg]{base} classes will be re-mapped, setting  all sub-\tsmeta{base} classes to \tsmeta{int}. }
\end{describelist*}
\begin{tsremark}
  A \tsmeta{base} can be based on other \tsmeta{bases}. Keep in mind, though, no attempt is made to detect a circular definition, which will end exhausting \LaTeXe{} memory. 
\end{tsremark}

As briefly presented in the introduction above, a key concept of all sets (language, keywords, highlight) is the idea of a \tsobj[marg]{class}, an integer, which allows to have many formatting \tsobj[marg]{classes} associated with each element.

%Regarding the \tsobj[key]{based on} key, when defining a set based on another one, one has the option to just copy the definitions as is, or \emph{remap} the base classes, either setting them to a constant, \tsobj[key]{S[int]}\tsobj[marg]{base}, or add a constant \tsfmt[value]{R[int]\tsobj[meta]{base}} to them.
\begin{tsremark}
  When processing the many sets (base format, see \ref{codehl:syntax:basedon}, highlight, see \ref{codehl:syntax:hlset}, keywords, see \ref{codehl:syntax:keywd} or language, see \ref{codehl:syntax:lang}) the \tsobj[key]{based on} keys are processed first in the definition order.
  
  Moreover, the \tsobj[key]{based on} definitions can be nested. For instance, one can have a language \tsobj[value]{langA} based on languages \tsobj[value]{langB,langC}, and \tsobj[value]{langB} based on \tsobj[value]{langD}, and so on.
\end{tsremark}

\subsection{Internal structures and scan functions}\label{codehl:building:defs}
Prior effectively displaying/highlighting some code, a set of scan functions (derived from the language definition, see \ref{codehl:syntax:lang}) and auxiliary variables (derived from keywords sets, see \ref{codehl:syntax:keywd}, highlight sets, see \ref{codehl:syntax:hlset} and base format, see \ref{codehl:syntax:baseformat}) need to be set. Note though:
\begin{itemize}
  \item Those scan functions and variables will always be locally defined. This allows to, for instance, have a local set of keywords extending a base set, but not changing it.
\end{itemize}

Depending on the specifics, setting up the needed scan functions (for a language) and auxiliary variables can be a time consuming operation. That's why setting those functions/variables is delayed as much as possible, eventually to the first call of \tsobj{\hlSettings} (see \ref{codehl:settings}). Usually this is ok, but, if \tsobj{\hlSettings} is called from inside a local group (like inside an environment) this can lead to the undesirable side effect of rebuilding those functions/variables time and time again.

\subsection{Package settings}\label{codehl:pkg:settings}
\begin{codedescribe}{ \hlPkgSettings , \codehl_pkg_settings:n }
\begin{codesyntax}%
\tsmacro{\hlPkgSettings}{settings}
\tsmacro{\codehl_pkg_settings:n}{settings}
\end{codesyntax}
This is meant to change some global settings. For now, \tsobj[marg]{settings} can only be:
  \begin{describelist*}{key}
    \describe{info/note}
    {(default: \tsobj[value]{note}) Possible values: \tsobj[values]{note,info,none}
     If set to \tsobj[value]{note} the \tsobj[key]{info/note} key from \tsobj{\codehl_lang_def:nn} (see \ref{codehl:syntax:lang}) and \tsobj{\codehl_keyset_def:nn} (see \ref{codehl:syntax:keywd}) will be logged into the terminal and log file. If set to \tsobj[value]{info} it will be logged only into the log file. If set to \tsobj[value]{none}, they will be ignored. Note, the package's default is \tsobj[key]{info/note = note}.}
  \end{describelist*}
\end{codedescribe}

\subsection{Base Format}\label{codehl:syntax:baseformat}
A base format defines general aspects of code highlighting, as framing, background color (if any), font, etc. By default, there is an initial set, \tsobj[key]{std-basefmt}, which only sets the \tsobj[key]{text width} to \tsverb[value]{\linewidth} and \tsobj[key]{wrap indent} to \tsobj[value]{2em}, besides \tsobj[key]{base format} to \tsobj{\ttfamily\footnotesize} (the full setup can be seen with \tsobj{\hlBasefmtShow{std-basefmt}}).

\begin{codedescribe}{ \hlBasefmtDef , \codehl_basefmt_def:nn }
\begin{codesyntax}%
\tsmacro{\hlBasefmtDef}{basefmt-set,keys}
\tsmacro{\codehl_basefmt_def:nn}{basefmt-set,keys}
\end{codesyntax}
\end{codedescribe}
\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
  \describe{based on}
    {\tsfmt[value]{\{ \tsobj[meta]{basefmt-set$_1$} , \tsobj[meta]{basefmt-set$_2$} \dots \}}
    
    The definitions of \tsobj[marg]{basefmt-set$_i$} set(s) are inherited. See \ref{codehl:syntax:basedon} for details. }

    \describe{info/note}
      { \tsargs[marg]{note}
      
      \tsobj[marg]{note} will be logged into the log file. This is merely informational and can be suppressed with the command \tsobj{\codehl_pkg_settings} (see \ref{codehl:pkg:settings}).
      }

\describe{~}{\color{black!50!red}\textbf{Behaviour  keys:}}

  \describe{gobble}
    {(default: \tsobj[value]{0}) The number of characters to be gobble from each line prior any processing.}
    \begin{tsremark}
      There is no provision for utf8 chars here. It will fail badly if an utf8 character is present among the characters to be gobbled. The main purpose of this is to de-indent source code.
    \end{tsremark}

  \describe{inline}
    {(default: \tsobj[value]{false}) Normally the code is displayed in vertical mode, constraining its width. With \tsobj[key]{inline} set to true, the code to be highlighted will be assumed to be short and displayed in its natural length.
    }
    \begin{tsremark}
      A \tsfmt[verb]{\^{}\^{}J} found in the middle of \tsobj[marg]{code} will result in a line break, except the one at the end of \tsobj[marg]{code}.
    \end{tsremark}
  \describe{add endmark}
  {(default: \tsobj[value]{false}) This will add a \tsfmt[verb]{\^{}\^{}J} at the end of \tsobj[marg]{code} (see \ref{codehl:display}) before it's further processed. This might be needed (to avoid a quark loop, see \citepkg[The l3quark module]{expl3}) in case of verbatim code grabbed by other means than  the \citepkg{codeverbatim} package, since the \tsobj{\hlDisplay} command expects the verbatim code to be terminated with a \tsfmt[verb]{\^{}\^{}J} (following the convention used  by \tsobj{\tl_retokenize:n} see \citepkg[Reassigning category code]{expl3}).
  }

  \describe{~}{\color{black!50!red}\textbf{Format  keys:}}
  \describe{base format}
    {This will be applied in a local group in which all highlighted code will be displayed. This shouldn't absorb any token.}

  \describe{show spaces}
    {(default: \tsobj[value]{false}) If spaces are shown or not.}

  \describe{text width}
    {(default: \tsverb**[value]{\linewidth}) This set's the text width of the displayed code.}
  \describe{wrap indent}
    {(default: \tsobj[value]{2em}) The indentation amount to be used in case of wrapping lines.}
  \describe{background}
    {Set's the background color to be used. Can be any color as defined by \tsobj[pkg]{xcolor}. By default no background is applied (equivalent to an empty argument).}

  \describe{~}{\color{black!50!red}\textbf{Line numbers  keys:}}
  \describe{numbers }
    {(default: \tsobj[value]{none}) Possible values: \tsobj[value]{none,left,right}. Line numbers will be attached (or not) to each line.}
  \describe{numbers format}
    {Format to be used when displaying line numbers. The used command(s) can absorb a single parameter, namely the line number. }
  \describe{numbers sep}
    {(default: \tsobj[value]{2pt}) The separation between the displayed text and the line numbers.}

  \describe{~}{\color{black!50!red}\textbf{Frame  keys:}}
  \describe{rule width}
    {(default: \tsobj[value]{0.25pt}) The width of the rules (if any) when framing the text.}

  \describe{rule color}
    {(default: \tsobj[value]{black}) The color of the rules (if any) when framing the text.}

  \describe{left frame}
    {(default: \tsobj[value]{false}) If a rule at the left should be present.}
  \describe{right frame}
    {(default: \tsobj[value]{false}) If a rule at the right should be present.}
  \describe{top frame}
    {(default: \tsobj[value]{false}) If a rule at the top should be present.}
  \describe{bottom frame}
    {(default: \tsobj[value]{false}) If a rule at the bottom should be present.}

  \describe{frame sep}
    {(default: \tsobj[value]{2pt}) The separation between the frames (if any) and the text.}
  \describe{left sep}
    {(default: \tsobj[value]{0pt}) Extra separation (added to \tsobj[key]{frame sep} between the left frame and the text.}
  \describe{right sep}
    {(default: \tsobj[value]{0pt}) Extra separation (added to \tsobj[key]{frame sep} between the right frame and the text.}
  \describe{top sep}
    {(default: \tsobj[value]{0pt}) Extra separation (added to \tsobj[key]{frame sep} between the top frame and the text.}
  \describe{bottom sep}
    {(default: \tsobj[value]{0pt}) Extra separation (added to \tsobj[key]{frame sep} between the bottom frame and the text.}

\end{describelist*}


\subsection{Highlight Sets}\label{codehl:syntax:hlset}

A Highlight set defines the formatting to be applied to the many detected elements (as defined by language \ref{codehl:syntax:lang}). The formats commands can absorb a single argument, namely the text/element detected and being formatted. By default, there is an initial set, \tsobj[key]{std-hlset}, which  sets \tsobj[key]{comment} (classes 1 to 4) to \tsverb[value]{\itshape}, \tsobj[key]{string} (classes 1 to 4) to \tsverb[value]{\slshape} and  \tsobj[key]{keywd,texcs} (classes 1 to 4) to \tsverb[value]{\slshape} (the full setup can be seen with \tsobj{\hlHLsetShow{std-hlset}}). \tsobj[key]{std-hlset} is just for convenience, allowing for a quick and simple setup (like in \ref{examples}).

\begin{codedescribe}{ \hlHLsetDef , \codehl_hlset_def:nn }
\begin{codesyntax}%
\tsmacro{\hlHLsetDef}{hlset-set,keys}
\tsmacro{\codehl_hlset_def:nn}{hlset-set,keys}
\end{codesyntax}
\end{codedescribe}
All keys (except for \tsobj[key]{based on}) expect two arguments: \tsargs[marg]{class,fmt-cmds}. 

\tsobj[marg]{fmt-cmds} can absorb a single argument. The \tsobj[marg]{class} (an integer) allows to have distinct formats for the same structure (be it comments, strings, keywords, etc...).

\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
  \describe{based on}
    { \tsfmt[value]{\{ \tsobj[meta]{hlset-ref$_1$} , \tsobj[meta]{hlset-ref$_2$} \dots \}}
    
    The definitions of a base \tsobj[marg]{hlset-set$_i$} set(s) are inherited. See \ref{codehl:syntax:basedon} for details. }
  
    \describe{info/note}
      { \tsargs[marg]{note}
      
      \tsobj[marg]{note} will be logged into the log file. This is merely informational and can be suppressed with the command \tsobj{\codehl_pkg_settings} (see \ref{codehl:pkg:settings}).
      }
  \describe{comment}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to \tsobj[key]{comments}.  }
  \describe{string}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to \tsobj[key]{strings}.  }
  \describe{keywd}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to \tsobj[key]{keywords}.  }
  \describe{emph}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to \tsobj[key]{keywords}, this is just an alternative way to format keywords (similar to \citepkg{listings} extra emphasis).  }
  \describe{active}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to \tsobj[key]{active} comments.  }
  \describe{\tsmeta{id-name}}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to identifiers named \tsmeta{id-name}. See \ref{codehl:syntax:lang} for details }
  \describe{\tsmeta{tag-name}}
    {\tsargs[marg]{class,fmt-cmds}  To be applied to (tagged) keywords inside a \tsobj[key]{tagged area}. See \ref{codehl:syntax:lang} for details }
    
  \begin{tsremark}
    Since this is decoupled (at definition time) from language and keyword sets, any other \tsobj[key]{key} being used will be treated as a possible identifier (\tsobj[marg,or]{id-name,tag-name} see \ref{codehl:syntax:lang}), and no error will be raised.
  \end{tsremark}
  \begin{tsremark}
    If you want to delete the format associated with any given \tsobj[key]{key} \tsobj[marg]{class} pair, just redefine them as nothing, e.g., \tsobj[key]{keywd = \{2\}\{\}}.
  \end{tsremark}
\end{describelist*}

\subsection{Auxiliary Format Commands}

\begin{codedescribe}{ \hlFmt, \hlSetFmt, \codehl_hlset_fmt:nn,  \codehl_hlset_fmt:nnn }
\begin{codesyntax}%
\tsmacro{\hlFmt}{id,class}
\tsmacro{\hlSetFmt}{hlset-set,id,class}
\tsmacro{\codehl_hlset_fmt:nn}{id,class}
\tsmacro{\codehl_hlset_fmt:nnn}{hlset-set,id,class}
\end{codesyntax}
These are meant to be used in the definition of \tsobj[marg]{fmt-cmds}, see \ref{codehl:syntax:hlset}. The versions with two parameters (\tsobj[marg]{id,class}) use the current active set, whilst the ones with three parameters allow to reference the entries from a different highlight set. \tsobj[marg]{id} can be any highlight set key: \tsobj[key,comma]{comment,string,keywd,emph,active} or any \tsobj[key,or]{id-name,tag-name}. See \ref{codehl:syntax:hlset}.
\end{codedescribe}
  \begin{tsremark}
    Since this is decoupled (at definition time) from any language, highlight set and/or keyword set, no error will be raised if referencing a non-existent \tsobj[marg,or]{hlset-set,id,class}.
  \end{tsremark}
  \begin{tsremark}
    These commands can be used anywhere, given that the corresponding highlight set was already processed (see \ref{codehl:settings} and \ref{codehl:building:defs}), though an \emph{active set} is only well defined in the context of display commands, see \ref{codehl:display}.
  \end{tsremark}

\subsection{Keywords Sets}\label{codehl:syntax:keywd}

Sets of \emph{detectable} keywords. These defines the list of keywords and associated formatting \tsobj[marg]{class}.

\begin{codedescribe}{ \hlKeysetDef , \codehl_keyset_def:nn }
\begin{codesyntax}%
\tsmacro{\hlKeysetDef}{keyset-set,keys}
\tsmacro{\codehl_keyset_def:nn}{keyset-set,keys}
\end{codesyntax}
\end{codedescribe}
All keys (except for \tsobj[key]{based on}, see \ref{codehl:syntax:basedon}) expect two arguments: \tsargs[marg]{class,keywd-list}. 
Besides that, one can add an asterisk or an exclamation mark to each key, for instance: (a) \tsobj[key,or]{keywd*,emph*}, in which case the list of keywords will be converted to lower case (using \tsobj{\str_lowercase:n}),  or (b) \tsobj[key,or]{keywd!,emph!}, in which case the list of keywords will be converted to upper case (using \tsobj{\str_uppercase:n}).

The \tsobj[marg]{class} (an integer) allows to have distinct sets of keywords, identifiers.

\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
  \describe{based on} { \{ \tsobj[meta]{keyset-set$_1$} , \tsobj[meta]{keyset-set$_2$} \dots \}
    
    The definitions of a base \tsobj[marg]{keyset-set$_i$} set are inherited. See \ref{codehl:syntax:basedon} for details. }
    \describe{info/note}
      { \tsargs[marg]{note}
      
      \tsobj[marg]{note} will be logged into the log file. This is merely informational and can be suppressed with the command \tsobj{\codehl_pkg_settings} (see \ref{codehl:pkg:settings}).
      }
  
  \describe{keywd}
    { \tsargs[marg]{class,keywords list}  List of keywords.  }
  \describe{emph}
    { \tsargs[marg]{class,keywords list}  List of keywords to be formatted as \tsobj[key]{emph}.  }
  \describe{\tsmeta{id-name}}
    { \tsargs[marg]{class,keywords list}  List of \tsmeta{id-name} (\tsobj[key]{identifiers}) keywords  to be formatted as \tsobj[key]{id-name} in \ref{codehl:syntax:hlset}.  See \tsobj[key]{identifiers} from \ref{codehl:syntax:lang} for details }
  \describe{\tsmeta{tag-name}}
    { \tsargs[marg]{class,keywords list}  List of keywords, \tsmeta{tag-name},  to be formatted as \tsobj[key,marg]{tag-name} (see \ref{codehl:syntax:hlset}) inside a \tsobj[key]{tagged area}.  See \ref{codehl:syntax:lang} for details }
  \begin{tsremark}
    Since this is decoupled (at definition time) from language and highlight format, any other \tsobj[key]{key} being used will be treated as a possible identifier (see \ref{codehl:syntax:lang}), and no error will be raised.
  \end{tsremark}
  \describe{suppress \tsmeta{id-name}}
    { \tsargs[marg]{class,keywords list}  List of \tsmeta{id-name} keywords whose format (if already defined) will be suppressed. \tsobj[marg]{id-name} can also be \tsobj[key,or]{keywd,emph}. \tsobj[marg]{class} isn't used, it's needed just to preserve the same use pattern of the other keys.}
  \begin{tsremark}
    Since this is decoupled (at definition time) from language and highlight format, no error will be raised if a keyword wasn't already defined.
  \end{tsremark}
  \begin{tsremark}
   Again, each keyword can be postfixed with (a) an asterisk, in which case the list of keywords will be converted to lower case (using \tsobj{\str_lowercase:n}) or (b) an exclamation mark, in which case the list of keywords will be converted to upper case (using \tsobj{\str_uppercase:n}). This is meant for case insensitive languages.
  \end{tsremark}
\end{describelist*}


\subsection{Language Syntax}\label{codehl:syntax:lang}
The elements of a language (for instance, comments, strings) are defined in terms of their delimiters. There are 4 main cases:
\begin{itemize}
  \item keywords: any combination of letters. That's  \emph{implicit} for all languages.
  \item Identifiers: keywords preceded by a marker (\tsobj[marg]{start-pattern} below), like \TeX{} commands. 
  \item Fully delimited elements (those with \tsobj[marg]{start-pattern,end-pattern} below), like C++ comments starting with \tsobj[key]{/*} and ending with \tsobj[key]{*/}, or strings.
  \item Line delimited elements (those with \tsobj[marg]{start-pattern} below), like C single line comments starting with \tsobj[key]{//}.
\end{itemize}
\begin{tsremark}
  When defining the patterns, don't forget to escape \TeX{} special characters, specially  the ones with category code besides \emph{other} (12) and \emph{letter} (11):  
0: escape itself (usually \tsverb{\ }), 
1: begin-group (usually \tsfmt{\{} ), 
2: end-group (usually \tsfmt{\}} ), 
3: math shift (usually \tsfmt{\$} ), 
4: alignment tab  (usually \tsfmt{\&} ), 
6: parameter  (usually \tsfmt{\#} ), 
7: superscript  (usually \tsfmt{\^{}} ) ,
8: subscript (usually \tsfmt{\_} ) ,
14: comment (usually \tsfmt{\%} ).

In fact, all characters can be escaped, for instance \tsverb**[verb]{{\a\d\:\$}} is, effectively, \tsverb[verb]{{ad:$}}
\end{tsremark}
\begin{tsremark}[\color{red}Attention:]
  When processing the \tsobj[marg]{patterns}, no expansion will occur, and all characters in the given pattern will receive the category code other. For instance, given a pattern \tsverb**[verb]{{\cmdX}} the effective pattern will be \tsverb**[verb]{{cmdX}}.
\end{tsremark}

All structures can be nested inside others, but only a few can \emph{hold} them, namely: a \tsobj[key]{string} can be nested into \tsobj[key,or]{string, delimited string}, whilst a \tsobj[key]{comment} can be nested into \tsobj[key,or]{comment,comment line, comment line at}. The option \tsobj[key]{nestable} controls which ones can be detected (if nested).

In case of the \tsobj[key]{discard} variants, obviously a \tsobj[marg]{class} isn't really needed (no formatting), but it's required so that its syntax is the same as the \tsobj[key]{comment} counter parts, which allows one to just add or remove a \tsobj[key]{discard} word, as needed.

When analysing the text to be highlighted, the listed patterns are grouped by their first letter, then the rest of the pattern is looked for in the \emph{reverse} definition order, that means, for example, if one has two comment definitions, like 
\tsverb[key]{comment = {3}{/**}{**/}} followed by \tsverb[key]{comment = {1}{/*}{*/}} the \tsverb[key]{/**} will never be detected, always put the longest sequence last.
\begin{tsremark}
  If two structures are defined with the same \tsobj[marg]{start-pattern} the one defined last overwrites any previous definition for that  \tsobj[marg]{start-pattern}.
\end{tsremark}

\begin{codedescribe}{ \hlLangDef , \codehl_lang_def:nn }
\begin{codesyntax}%
\tsmacro{\hlLangDef}{lang,keys}
\tsmacro{\codehl_lang_def:nn}{lang,keys}
\end{codesyntax}
\end{codedescribe}

  In the following, \tsobj[marg]{options} can any combination of the following:
  \begin{describelist*}{keys}
    \describe{nestable}{The construct will be detected if nested inside another likewise structure: comments inside comments, or strings/identifiers inside strings.}
    \begin{tsremark}
      Any \tsobj[key]{comment} construct declared as \tsobj[key]{nestable} will be detected if inside \tsobj[key,or]{comment. comment line, comment line at}.
      
      A \tsobj[key,or]{string,identifier} construct declared as \tsobj[key]{nestable} will be detected if inside \tsobj[key,or]{string, delimited string}.
    \end{tsremark}
    \describe{tagged}{The construct will only be detected inside a tagged area.}
    \describe{non tagged}{The construct will only be detected outside a tagged area.}
    \begin{tsremark}
      If none is given, the construct will be detected by default (including inside a tagged area), but not inside other structures, like comments or strings.
    \end{tsremark}
    
%    \begin{tsremark}[REVIEW THIS!]\color{red}
%      The many \tsobj[keys]{discard comment,active comment} aren't affected by the \tsobj[key,or]{tagged,non tagged} keys.
%    \end{tsremark}
  \end{describelist*}
\tsobj[marg]{keys} can be any combination of:
\begin{describelist*}{keys}
    \describe{based on}
    {  \tsfmt[value]{\{ \tsobj[meta]{lang-set$_1$} , \tsobj[meta]{lang-set$_2$} \dots \}}
    
    The definitions of a base \tsobj[meta]{lang-set$_i$} are inherited. See \ref{codehl:syntax:basedon} for details. }
    \describe{info/note}
      { \tsargs[marg]{note}
      
      \tsobj[marg]{note} will be logged into the log file. This is merely informational and can be suppressed with the command \tsobj{\codehl_pkg_settings} (see \ref{codehl:pkg:settings}).
      }

    \describe{~}{\color{black!50!red}\textbf{Keywords/identifiers behaviour keys:}}    
    

    \describe{keywd in string}
      {(default: \tsobj[value]{false}) If keywords (and/or identifiers) are to be detected (and formatted) inside strings.  }
      \begin{tsremark}
        In case of identifiers, they must be declared as \tsobj[key]{nestable} too.
      \end{tsremark}
    \describe{case sensitive}
      {(default: \tsobj[value]{true}) Possible values: \tsobj[value,or]{true,false,lower case,upper case}.  If keywords (and/or identifiers) are case sensitive or not, and how they have to be normalized (upper or lower case, if case insensitive) before comparing them with an existing keyword set.}
      \begin{tsremark}
      If set to \tsobj[value,or]{false,lower case} (case insensitive) a 'keyword candidate' will be converted to lower case prior comparing it with any list of defined keywords, identifiers or tag names (see \ref{codehl:syntax:keywd}). If set to \tsobj[value]{upper case} (also case insensitive) a 'keyword candidate' will be converted to upper case. This implies that, it will only work IF the keywords lists are made of, respectively,  lower or upper case keywords.
      \end{tsremark}
      
    \describe{alphanumeric}
      {(default: \tsobj[value]{false}) If set to false (default) keywords and/or identifiers may only contain letters. If set to true they may start with \tsobj[key]{oletter} chars (besides letters) and may also contain \tsobj[key,or]{oletter,digits} chars.}
      \begin{tsremark}
        This might interfere, in some cases, with other patterns, suppressing them if they start with one of the characters listed as \tsobj[key,or]{digits,oletter}. The best approach would be to just capture those characters as letter (see \citepkg[{Characters Category Code and Common Keys},{catcode commands}]{codeverbatim}).
      \end{tsremark}  
    \describe{digits}
    { \tsargs[marg]{dig-set}
    
    Sets the list of what a \tsobj[key]{digit} is. A regular expression composed of the range 0-9 plus \tsobj[marg]{dig-set} will be constructed as \tsfmt{[0-9\tsobj[marg]{dig-set}]} (see section \citepkg*[Character classes]{expl3}). This only applies if, and only if, \tsobj[key]{alphanumeric} is set to true.
    }
    \describe{digits*}
    { \tsargs[marg]{dig-set}
    
    Sets the list of what a \tsobj[key]{digit} is. A regular expression composed only of \tsobj[marg]{dig-set} will be constructed as \tsfmt{[\tsobj[marg]{dig-set}]} (see the section \citepkg*[Character classes]{expl3} ). This only applies if, and only if, \tsobj[key]{alphanumeric} is set to true.
    }
    
    \describe{oletter}
    { \tsargs[marg]{o-set}
    
    Sets the list of what a \tsobj[key]{oletter} is. A regular expression composed only of \tsobj[marg]{o-set} will be constructed as \tsfmt{[\tsobj[marg]{o-set}]} (see the section \citepkg*[Character classes]{expl3}). This only applies if, and only if, \tsobj[key]{alphanumeric} is set to true.
    }
\begin{tsremark}
  Regarding \tsobj[key]{alphanumeric,digits,oletter},  it is slightly better (performance wise) to just set those as letter (category code 11) and avoid the extra overhead, setting \tsobj[key]{alphanumeric} to false.
\end{tsremark}
    \describe{~}{\color{black!50!red}\textbf{Pattern keys:}}    

    \describe{identifier}
      { \tsargs[marg]{id-name,start-pattern,options}
        
        The keyword following \tsobj[marg]{start-pattern} (including the  \tsobj[marg]{start-pattern} itself) will be formatted as defined by \tsobj[key]{id-name}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ).
      }

    \describe{tagged area}
      { \tsargs[marg]{tag-name,start-pattern,end-pattern,options}
      
        In the region enclosed by \tsobj[marg]{start-pattern,end-pattern} the usual keywords (the ones defined using the key \tsobj[key]{keywd} in a \tsobj[marg]{keyset-set}, see \ref{codehl:syntax:keywd}) won't be detected but only the ones declared as \tsobj[marg]{tag-name}. This aims at languages like \tsobj[pkg,or]{html,php}. If a \tsobj[key]{tagged area} is declared as \tsobj[value]{nestable} it can appear inside a string (for instance, like \tsobj[pkg]{php}).
      }

    \describe{comment}
      { \tsargs[marg]{class,start-pattern,end-pattern,options}
      
      Everything between \tsobj[marg]{start-pattern} and \tsobj[marg]{end-pattern}, including them, will be formatted as defined by \tsobj[key]{comment}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ).
      }
    \describe{comment line}
      { \tsargs[marg]{class,start-pattern,options}

      Everything between \tsobj[marg]{start-pattern} and the end of line, will be formatted as defined by \tsobj[key]{comment}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ).
      }
    \describe{comment line at}
      { \tsargs[marg]{class,start-pattern,col,options}

      Everything between \tsobj[marg]{start-pattern} and the end of line, will be formatted as defined by \tsobj[key]{comment}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ), but only if the first character appears at column \tsobj[marg]{col}.
      }
    \describe{discard comment}
      { \tsargs[marg]{class,start-pattern,end-pattern,options}
      
      Everything between \tsobj[marg]{start-pattern} and \tsobj[marg]{end-pattern}, including them, will be discarded. The \tsobj[marg]{class} is here just so this has the same construct as \tsobj[key]{comment}.
      }
    \describe{discard comment line}
      { \tsargs[marg]{class,start-pattern,options}
      
      Everything between \tsobj[marg]{start-pattern} and the end of line will be discarded. The \tsobj[marg]{class} is here just so this has the same construct as \tsobj[key]{comment line}.
      }
    \describe{discard comment line at}
      { \tsargs[marg]{class,start-pattern,col,options}
      
      Everything between \tsobj[marg]{start-pattern} and the end of line will be discarded, but only if the first character appears at column \tsobj[marg]{col}. The \tsobj[marg]{class} is here just so this has the same construct as \tsobj[key]{comment line at}.
      }
    \describe{active comment}
      { \tsargs[marg]{class,start-pattern,end-pattern,options}
      
      Everything between \tsobj[marg]{start-pattern} and \tsobj[marg]{end-pattern}, excluding them, will be: (1)  executed as \LaTeXe{} commands. (2) formatted as defined by \tsobj[key]{active}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ).
      }
    \describe{active comment line}
      { \tsargs[marg]{class,start-pattern,options}
      
      Everything between \tsobj[marg]{start-pattern} and the end of line will: (1)  executed as \LaTeXe{} commands. (2) formatted as defined by \tsobj[key]{active}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ).
      }
    \describe{active comment line at}
      { \tsargs[marg]{class,start-pattern,col,options}
      
      Everything between \tsobj[marg]{start-pattern} and the end of line will: (1)  executed as \LaTeXe{} commands. (2) formatted as defined by \tsobj[key]{active}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ). But only if the first character appears at column \tsobj[marg]{col}.
      }
    \describe{string}
      { \tsargs[marg]{class,pattern,escape-char,options}
      
      Everything between \tsobj[marg]{pattern} and \tsobj[marg]{pattern}, including them, will be formatted as defined by \tsobj[key]{string}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ). The \tsobj[marg]{escape-char} assures the following character won't be interpreted as a pattern delimiter of any kind.
      }
    \describe{delimited string}
      { \tsargs[marg]{class,start-pattern,end-pattern,escape-char,options}
      
      Everything between \tsobj[marg]{start-pattern} and \tsobj[marg]{end-pattern}, including them, will be formatted as defined by \tsobj[key]{string}\tsobj[marg]{class} (from \tsobj[marg]{hlset-set} ). The \tsobj[marg]{escape-char} assures the following character won't be interpreted as a pattern delimiter of any kind.
      }

    \describe{replace}
      { \tsargs[marg]{org-str,replacement}
      
        Any occurrence of \tsobj[marg]{org-str} will be replaced by \tsobj[marg]{replacement}. Note that \tsobj[marg]{org-str} will be processed as any \tsobj[marg]{pattern} in the previous keys, in particular, any space in it will be removed. Moreover, the scan routines will only look after those \tsobj[marg]{org-str} after scanning for other patterns, the main implication: if a \tsobj[marg]{org-str} starts with the same character used in any other pattern (comments, strings, etc.) this won't be recognized at all.
      }
    \describe{replace*}
      { \tsargs[marg]{org-str,replacement}
      
        Any occurrence of \tsobj[marg]{org-str} will be replaced by \tsobj[marg]{replacement}. Note that \tsobj[marg]{org-str} will be processed as any \tsobj[marg]{pattern} in the previous keys, in particular, any space in it will be removed. Unlike the previous key (without the asterisk) \tsobj[marg]{org-str} will be treated as any other pattern, keep in mind that, in this case, a \tsobj[marg]{org-str} might suppress the recognition of some other pattern (any previously defined one, starting with the same characters, but longer).
      }
    \describe{suppress}
      { \tsargs[marg]{pattern}
      
      The structure whose \tsobj[marg]{start-pattern} equals \tsobj[marg]{pattern} will be suppressed: no scan function will be generated for it. 
      }
      \begin{tsremark}
        It won't detect if the  \tsobj[marg]{pattern} corresponds, or not, to an already defined structure, given that the \tsobj[marg]{start-pattern} might be inherited from a \tsobj[key]{based on}  \tsobj[marg]{lang}.
      \end{tsremark}
      \begin{tsremark}
        Sequence matters: If, later on, a new structure is defined with the same \tsobj[marg]{start-pattern}, it will be normally processed (overwriting the \tsobj[key]{suppress} key).
      \end{tsremark}
\end{describelist*}

\subsection{Aliases}\label{codehl:aliases}

\begin{codedescribe}{ \hlLangAlias, \codehl_lang_alias:nn }
\begin{codesyntax}%
\tsmacro{\hlLangAlias}{alias,lang}
\tsmacro{\codehl_lang_alias:nn}{alias,lang}
\end{codesyntax}
These commands define a set of aliases for a language. Notice, thought, that the internal representation of those aliases will always be exactly one level deep. For instance you can define 'B' as an alias for 'A' then 'C' as an alias to 'B', in which case, internally, 'C' will be just another alias for 'A'. More important, if, later on, 'B' is redefined as an alias for 'X', 'C' will remain an alias for 'A'.
\begin{tsremark}
  An error will be raised if \tsobj[marg]{alias} is an already defined as a language (not an alias).
\end{tsremark}
\begin{tsremark}
  The alias definition will be logged into the log file. This can be suppressed with the command \tsobj{\codehl_pkg_settings} (see \ref{codehl:pkg:settings}).
\end{tsremark}

\end{codedescribe}

\begin{codedescribe}{ \hlKeysetAlias, \codehl_keyset_alias:nn }
\begin{codesyntax}%
\tsmacro{\hlKeysetAlias}{alias,keyset}
\tsmacro{\codehl_keyset_alias:nn}{alias,keyset}
\end{codesyntax}
Same, for a keyword set. 
\end{codedescribe}

\begin{codedescribe}{ \hlHLsetAlias , \codehl_hlset_alias:nn }
\begin{codesyntax}%
\tsmacro{\hlHLsetAlias}{alias,hlset}
\tsmacro{\codehl_hlset_alias:nn}{alias,hlset}
\end{codesyntax}
Same, for a highlight set.
\end{codedescribe}

\begin{codedescribe}{ \hlBasefmtAlias , \codehl_basefmt_alias:nn }
\begin{codesyntax}%
\tsmacro{\hlBasefmtAlias}{alias,basefmt}
\tsmacro{\codehl_basefmt_alias:nn}{alias,basefmt}
\end{codesyntax}
Same, for a base format set. 
\end{codedescribe}

\begin{codedescribe}{ \hlSettingsAlias, \codehl_settings_alias:nn }
\begin{codesyntax}%
\tsmacro{\hlSettingsAlias}{alias,settings-id}
\tsmacro{\codehl_settings_alias:nn}{alias,settings-id}
\end{codesyntax}
Same, for a settings set. 
\end{codedescribe}


\subsection{Show Commands}\label{codehl:show}

The following commands can be used to see what is currently defined and also which pre-defined sets (see \ref{codehl:lang:predef}) are registered for use.

\begin{codedescribe}{ \hlBasefmtShow , \codehl_basefmt_show:n }
\begin{codesyntax}%
\tsmacro{\hlBasefmtShow}{basefmt-set}
\tsmacro{\codehl_basefmt_show:n}{basefmt-set}
\end{codesyntax}
This will write to the terminal (raising an error message) the effective \tsobj[marg]{basefmt-set}, after applying defaults and recovering all \tsobj[key]{based on} definitions.
\end{codedescribe}


\begin{codedescribe}{ \hlHLsetShow , \codehl_hlset_show:n }
\begin{codesyntax}%
\tsmacro{\hlHLsetShow}{hlset-set}
\tsmacro{\codehl_hlset_show:n}{hlset-set}
\end{codesyntax}
This will write to the terminal (raising an error message) the effective \tsobj[marg]{hlset-set} (after recovering all \tsobj[key]{based on} definitions).
\end{codedescribe}


\begin{codedescribe}{ \hlKeysetShow , \codehl_keyset_show:n }
\begin{codesyntax}%
\tsmacro{\hlKeysetShow}{keyset-set}
\tsmacro{\codehl_keyset_show:n}{keyset-set}
\end{codesyntax}
This will write to the terminal (raising an error message) the effective \tsobj[marg]{keyset-set} (after  recovering all \tsobj[key]{based on} definitions).
\end{codedescribe}


\begin{codedescribe}{ \hlLangShow , \codehl_lang_show:n }
\begin{codesyntax}%
\tsmacro{\hlLangShow}{lang}
\tsmacro{\codehl_lang_show:n}{lang}
\end{codesyntax}
This will write to the terminal (raising an error message) the effective \tsobj[marg]{lang} definitions (after recovering all \tsobj[key]{based on} definitions).
\end{codedescribe}

\begin{codedescribe}{ \hlSettingsShow , \codehl_settings_show:n }
\begin{codesyntax}%
\tsmacro{\hlSettingsShow}{settings-id}
\tsmacro{\codehl_settings_show:n}{settings-id}
\end{codesyntax}
This will write to the terminal (raising an error message) the \tsobj[marg]{settings-id} definition. If called with an empty argument, \tsobj{\hlSettingsShow{}}, it will log the currently active settings.
\end{codedescribe}

\begin{codedescribe}{ \hlShow , \codehl_show:n }
\begin{codesyntax}%
\tsmacro{\hlShow}{keys}
\tsmacro{\codehl_show:n}{keys}
\end{codesyntax}
where \tsobj[marg]{keys} can be any combination of the following:
\end{codedescribe}
\begin{describelist*}{keys}
  \describe{registered lang}{This will log, all pre-defined language sets.}
  \describe{registered keyset}{This will log, all pre-defined keyword sets.}
  \describe{registered hlet}{This will log, all pre-defined highlight sets.}
  \describe{registered basefmt}{This will log, all pre-defined base format sets.}
  \describe{registered settings}{This will log, all pre-defined settings sets.}
  \begin{tsremark}
    In case of the \tsobj[key]{registered} keys, each entry will includes the file name where the sets can be found.
  \end{tsremark}
  \describe{defined lang}{This will log, the name of all currently defined language sets.}
  \describe{defined keyset}{This will log, the name of all currently defined keyword sets}
  \describe{defined hlset}{This will log, the name of all currently defined highlight sets.}
  \describe{defined basefmt}{This will log, the name of all currently defined base format sets. }
  \describe{defined settings}{This will log, the name of all currently defined settings sets. }
  \begin{tsremark}
    When listing these \tsobj[key]{defined} sets, in case of an alias, they will point to the effective set name.
  \end{tsremark}
  \describe{lang show}{
    \tsargs[marg]{lang-list}
    
    This expects a comma separated list of languages, \tsobj[marg]{lang-list}, and it will call \tsobj{\codehl_lang_show:n} for each one. Effectively logging each language structure.
    }
  \describe{lang show all}{
  
    This will call \tsobj{\codehl_lang_show:n} for every currently defined language. Logging them all.
    }
  \describe{keyset show}{
    \tsargs[marg]{keyset-list}
    
    This expects a comma separated list of keyword sets, \tsobj[marg]{keyset-list}, and it will call \tsobj{\codehl_keyset_show:n} for each one. Effectively logging each keyword set.
    }
  \describe{keyset show all}{
  
    This will call \tsobj{\codehl_keyset_show:n} for every currently defined keyword set. Logging them all.
    }
  \describe{hlset show}{
    \tsargs[marg]{hlset-list}
    
    This expects a comma separated list of highlight sets, \tsobj[marg]{hlset-list}, and it will call \tsobj{\codehl_hlset_show:n} for each one. Effectively logging each highlight set.
    }
  \describe{hlset show all}{
  
    This will call \tsobj{\codehl_hlset_show:n} for every currently defined highlight set. Logging them all.
    }
  \describe{basefmt show}{
    \tsargs[marg]{basefmt-list}
    
    This expects a comma separated list of base format sets, \tsobj[marg]{basefmt-list}, and it will call \tsobj{\codehl_basefmt_show:n} for each one. Effectively logging each base format set.
    }
  \describe{basefmt show all}{
  
    This will call \tsobj{\codehl_basefmt_show:n} for every currently defined base format set. Logging them all.
    }

  \describe{settings show}{
    \tsargs[marg]{settings-id-list}
    
    This expects a comma separated list of settings sets, \tsobj[marg]{settings-id-list}, and it will call \tsobj{\codehl_settings_show:n} for each one. Effectively logging each settings set. Additionally, it will log the currently active settings.
    }
  \describe{settings show all}{
  
    This will call \tsobj{\codehl_settings_show:n} for every currently defined settings set. Logging them all. Additionally, it will log the currently active settings.
    }
\end{describelist*}

\subsection{Pre-defined Sets}\label{codehl:lang:predef}
There is a set of pre-defined languages known by \tsobj[pkg]{codehighlight}, but since it would be wasteful to load all definitions all the time, those language definitions are \emph{stored} in auxiliary files.

Those auxiliary files will be loaded as needed, for instance when one tries to expand the definitions of a pre-defined language (\tsobj{\codehl_lang_def:nn}, see \ref{codehl:syntax:lang}), or defines a language based on a pre-defined one (key \tsobj[key]{based on}, see \ref{codehl:syntax:basedon}), or sets the display defaults (\tsobj{\codehl_settings:n}, see \ref{codehl:settings}).
\begin{tsremark}
  File loading, can only occurs in the preamble. An error will be raised otherwise.
\end{tsremark}
\begin{tsremark}[\color{red}Attention:]
  When defining a language, keyword set, highlight set, all definitions are local. This allows to, for instance, locally expand a keyword list, but it also has a side effect that, if an auxiliary file is loaded in a local group, the definitions will be lost.
\end{tsremark}

 The following commands, force the load of the needed auxiliary files, and should be used in the preamble. Note, though, that there isn't a one-to-one relationship between auxiliary packages and language/keyword sets, since some auxiliary packages might entice more than one language definition. Lastly, those commands keep track of which auxiliary files were already loaded, so  it's safe to call them more than once for the same language/keyword set.

\begin{codedescribe}{ \hlLangLoad , \codehl_lang_preload:n }
\begin{codesyntax}%
\tsmacro{\hlLangLoad}{lang-list}
\tsmacro{\codehl_lang_preload:n}{lang-list}
\end{codesyntax}
This will include the needed auxiliary packages. Whereas \tsobj[marg]{lang-list} is a comma separated list of languages.
\end{codedescribe}

\begin{codedescribe}{ \hlKeysetLoad , \codehl_keyset_preload:n }
\begin{codesyntax}%
\tsmacro{\hlKeysetLoad}{keyset-list}
\tsmacro{\codehl_keyset_preload:n}{keyset-list}
\end{codesyntax}
Similarly, whereas \tsobj[marg]{keyset-list} is a comma separated list of keyset sets.
\end{codedescribe}

\begin{codedescribe}{ \hlHLsetLoad , \codehl_hlset_preload:n }
\begin{codesyntax}%
\tsmacro{\hlHLsetLoad}{hlset-list}
\tsmacro{\codehl_hlset_preload:n}{hlset-list}
\end{codesyntax}
Similarly, whereas \tsobj[marg]{hlset-list} is a comma separated list of hlset sets.
\end{codedescribe}

\begin{codedescribe}{ \hlBasefmtLoad , \codehl_basefmt_preload:n }
\begin{codesyntax}%
\tsmacro{\hlBasefmtLoad}{basefmt-list}
\tsmacro{\codehl_basefmt_preload:n}{basefmt-list}
\end{codesyntax}
Similarly, whereas \tsobj[marg]{basefmt-list} is a comma separated list of basefmt sets.
\end{codedescribe}

\begin{codedescribe}{ \hlSettingsLoad , \codehl_settings_preload:n }
\begin{codesyntax}%
\tsmacro{\hlSettingsLoad}{settings-list}
\tsmacro{\codehl_settings_preload:n}{settings-list}
\end{codesyntax}
Similarly, whereas \tsobj[marg]{settings-list} is a comma separated list of settings sets.
\end{codedescribe}

\begin{tsremark}
  There is, currently, no predefined \tsobj[marg,or]{hlset,basefmt,settings} sets, besides \tsobj[marg]{std-basefmt, std-hlset} (which are always defined). This is just for command's symmetry, or in case someone asks for a feature similar to \citepkg{listings} \tsobj[value]{.prf} files (user predefined preferences).
\end{tsremark}

The following table contain the current list of known languages and keyword sets. 
A few remarks, first:
\begin{itemize}
  \item Languages like Fortran also have a pre-defined alias (in this case, just Fortran) normally pointing to the 'most recent' definition.  Note: if a new variant is introduced, the alias shall point to it.
  
  \item In most cases, when a language has multiple predefined sets, the last one (normally associated with the last version of them) is the more complete set, build upon the previous ones.
  \item In all cases, \tsobj{\hlLangShow} and/or \tsobj{\hlKeysetShow} can be used to verify the effective definitions.
  
  \item Some keyword's sets, \tsobj[marg]{keyset}, got split, either by an identifier (like \tsobj[key]{texcs} for \TeX{} or \tsobj[key]{php} for php) or classes. To document all fine details would be prone to error. In doubt, double check with \tsobj{\hlKeysetShow}.
  \item Languages belonging to the same family are, in general, hold together (for instance, the many FORTRAN keyword sets definitions).
  \item In most cases, the keyword sets are complete (to the author's knowledge), but in some cases it was needed to make some choices: the most glaring example \tsobj[value]{elisp.fullset} this is a separated set (single file) with nearly 6000 keywords, which where extracted from the documentation of it. Obviously, no practical way to verify them all, and (at best) questionable. In some other cases, it wasn't practical to have comprehensive lists, so the `most common/usual' (fuzzy definition, prone to errors) were included.
\end{itemize}

%\newpage
\begingroup
\footnotesize

\setlength{\arrayrulewidth}{0.04pt}

\begin{longtable}{p{15mm}p{40mm}p{41mm}p{38mm}}
  Language & Language sets & Keywords sets & Alias / Obs. \\\hline\\[-7.85pt]\endhead

\\[-7.85pt]
C &  \raggedright
  C.89 C.99 C.11  C.17  C.23 &  \raggedright
  C.89 C.99 C.11  C.17  C.23 &
  C $\!\rightarrow\!$ C.23  
     \\ \cline{2-4}

\\[-7.85pt]
C++ &  \raggedright
  C++.98  C++.11  C++.20  C++.23  &  \raggedright
  C++.98  C++.11  C++.20  C++.23  &
  C++ $\!\rightarrow\!$ C++.23  
     \\ \cline{2-4}

\\[-7.85pt]
Csharp &  \raggedright
  Csharp.1  Csharp.6  Csharp.11  Csharp.13 &  \raggedright
  Csharp.1  Csharp.6  Csharp.11  Csharp.13 &
  Csharp $\!\rightarrow\!$ Csharp.13  
     \\ \cline{2-4}
  
\\[-7.85pt]
java  &  \raggedright
  java.SE25 &  \raggedright
  java.SE25 &
  java $\!\rightarrow\!$ java.SE25  
     \\ \cline{2-4}

\\[-7.85pt]
python  &  \raggedright
  python.2.7   python.3.0  python.3.6  python.3.12 &  \raggedright
  python.2.7   python.3.0  python.3.6  python.3.12 &
  python $\!\rightarrow\!$ python.3.12  
     \\ \cline{2-4}
  
\\[-7.85pt]
SQL  &  \raggedright
  SQL.92  SQL.23 PL/SQL &  \raggedright
  SQL.92  SQL.23 PL/SQL SQL.PostgreSQL SQL.MySQL  &
  SQL  $\!\rightarrow\!$ SQL.23  
     \\ \cline{2-4}

\\[-7.85pt]
perl  &  \raggedright
  perl  &  \raggedright
  perl  &  
     \\ \cline{2-4}
  
\\[-7.85pt]
lua  &  \raggedright
  lua.5.5  &  \raggedright
  lua.5.5  &
  lua  $\!\rightarrow\!$ lua.5.5  
     \\ \cline{2-4}

\\[-7.85pt]
html  &  \raggedright
  html.5  &  \raggedright
  html.5  &
  html  $\!\rightarrow\!$ html.5  
     \\ \cline{2-4}

\\[-7.85pt]
php  &  \raggedright
  php.8  &  \raggedright
  php.8  php.mysqli  php.pgsql  php.xml-json  php.date  &
  php  $\!\rightarrow\!$ php.8  
     \\ \cline{2-4}
  
\\[-7.85pt]
JavaScript  &  \raggedright
  JavaScript  &  \raggedright
  JavaScript  &  
     \\ \cline{2-4}

\\[-7.85pt]
scala  &  \raggedright
  scala.3.10  &  \raggedright
  scala.3.10  &
  scala  $\!\rightarrow\!$ scala.3.10  
     \\ \cline{2-4}

\\[-7.85pt]
VisualBasic &  \raggedright
  VB.6  VB.8 VB.17  &  \raggedright
  VB.6 VB.8 VB.12 VB.17  &
  VisualBasic  $\!\rightarrow\!$ VB.17    VisualBasicClassic  $\!\rightarrow\!$ VB.6
     \\ \cline{2-4}

\\[-7.85pt]
Delphi &  \raggedright
  Delphi.7 Delphi.13  &  \raggedright
  Delphi.7 Delphi.XE8 Delphi.13  &
  Delphi  $\!\rightarrow\!$ Delphi.13    
     \\ \cline{2-4}

\\[-7.85pt]
Modula-2 &  \raggedright
  Modula-2  &  \raggedright
  Modula-2  &  
     \\ \cline{2-4}

\\[-7.85pt]
Oberon &  \raggedright
  Oberon Oberon+   &  \raggedright
  Oberon Oberon+  &  
     \\ \cline{2-4}

\\[-7.85pt]
COBOL &  \raggedright
  COBOL.74 COBOL.85 COBOL.02 &  \raggedright
  COBOL.74 COBOL.85 COBOL.02 &
  COBOL  $\!\rightarrow\!$ COBOL.02  
     \\ \cline{2-4}

\\[-7.85pt]
FORTRAN &  \raggedright
  FORTRAN.77 FORTRAN.95 FORTRAN.03 FORTRAN.18 &  \raggedright
  FORTRAN.77 FORTRAN.95 FORTRAN.03 FORTRAN.18 &
  FORTRAN  $\!\rightarrow\!$ FORTRAN.18  
     \\ \cline{2-4}

\\[-7.85pt]
Rust &  \raggedright
  Rust.1.99   &  \raggedright
  Rust.1.99 Rust.1.99.core Rust.1.99.alloc Rust.1.99.std Rust.1.99.all  &
  Rust  $\!\rightarrow\!$ Rust.1.99 
     \\ \cline{2-4}

\\[-7.85pt]
R &  \raggedright
  R   &  \raggedright
  R  &  
     \\ \cline{2-4}

\\[-7.85pt]
Ada &  \raggedright
  Ada.95 Ada.22   &  \raggedright
  Ada.95 Ada.22  &
  Ada  $\!\rightarrow\!$ Ada.22  
     \\ \cline{2-4}

\\[-7.85pt]
julia &  \raggedright
  julia.1.x   &  \raggedright
  julia.1.x   &
  julia  $\!\rightarrow\!$ julia.1.x  
     \\ \cline{2-4}

\\[-7.85pt]
Ruby &  \raggedright
  Ruby.4   &  \raggedright
  Ruby.4   &
  Ruby  $\!\rightarrow\!$ Ruby.4  
     \\ \cline{2-4}

\\[-7.85pt]
lisp &  \raggedright
  CL elisp   &  \raggedright
  CL elisp elisp.fullset   & 
  CommonLisp  $\!\rightarrow\!$ CL  
     \\ \cline{2-4}

\\[-7.85pt]
awk &  \raggedright
  awk.posix awk.gnu   &  \raggedright
  awk.posix awk.gnu   &  
     \\ \cline{2-4}

\\[-7.85pt]
postscript &  \raggedright
  postscript.level3   &  \raggedright
  postscript.level3   &
  postscript  $\!\rightarrow\!$ postscript.level3  
     \\ \cline{2-4}

\\[-7.85pt]
MetaFont &  \raggedright
  MetaFont   &  \raggedright
  MetaFont   &  
     \\ \cline{2-4}

\\[-7.85pt]
MetaPost &  \raggedright
  MetaPost   &  \raggedright
  MetaPost   &  
     \\ \cline{2-4}

\\[-7.85pt]
TeX  &  \raggedright
  TeX  &  \raggedright
  TeX.primites TeX.pdfTeX TeX.luaTeX TeX.common &  
     \\ \cline{2-4}

\\[-7.85pt]
TeX  &  \raggedright
  TeX  &  \raggedright
  TeX.ams TeX.babel TeX.bibtex TeX.hyperref TeX.kernel TeX.pgf TeX.pgfplots   TeX.xpacks &  
   from \tsobj[pkg]{codedescribe} 
     \\ \cline{2-4}

\\[-7.85pt]
TeX  &  \raggedright
  TeX.l3  &  \raggedright
  TeX.l3ams TeX.l3bibtex TeX.l3exp TeX.l3kernel TeX.l3pgf    &  
  from \tsobj[pkg]{codedescribe}. cmds contain \tsobj{_} 
     \\ \cline{2-4}

\\[-7.85pt]
TeX  &  \raggedright
  TeX.l3sign  &  \raggedright
  TeX.l3amssign TeX.l3bibtexsign TeX.l3expsign TeX.l3kernelsign TeX.l3pgfsign &  
  from \tsobj[pkg]{codedescribe}. cmds contain \tsobj{_ :} 
     \\ \cline{2-4}

\end{longtable}

\endgroup


\begin{codestore}[demo0X]
\hlKeysetDef{TeX.mydef}
  {
    based on = 
      {   
        TeX.primitives  ,
        S[2]TeX.common  , 
        R[5]TeX.ams     ,
        R[7]TeX.bibtex
      }
  }
\end{codestore}

%\newpage
A few closing notes/remarks:
\begin{itemize}
  \item In case of errors, the reader is invited to open an issue at\\[-4ex]
  
   \url{https://github.com/alceu-frigeri/codeverbatim}.
  \item ``In general'', when a language has single line comments mixed with multi line ones, the single line are defined as class 1, and the multi line as class 2. This allows (if necessary) to differentiate one from another. Same for strings, usually, the most common cases (a string delimited by \tsobj[code,or]{",'}) are defined as class 1, whilst others as class 2.
  \item All subject to change: at the end, it should be up to those who use those languages more regularly, what sets (and classes) are more reasonable. 
  \item a few languages have ``tagged areas''. When inside a tagged area, normal keywords aren't recognized but only the ``tagged ones'' (see \ref{codehl:lang:defs}). In particular \tsobj[value]{html} has a tagged area defined as \tsverb[key]{tagged area = { html }  { < }  { > }  { non tagged }}. The \tsobj[value]{ non tagged } assures it won't be recognized inside another tagged area. Moreover, the associated \tsobj[key]{keyset} defines keys associated with the identifier \tsobj[key]{html} (for instance, an usual html property like \tsobj[value]{div}, won't be recognized as a html keyword outside a tagged area).
  \item \tsobj[value]{php} is another such language (from it's definition: \tsverb[key]{tagged area = { php }  { <?php } { ?> } { nestable }}) with a twist: it is ``based on'' the definition of \tsobj[value]{html}, meaning any valid \tsobj[value]{html} construct will also be recognized, besides \tsobj[value]{php} ones, furthermore  they can appear inside \tsobj[value]{html} tagged areas, including \tsobj[value]{html} strings (the \tsobj[key]{nestable} in the \tsobj[value]{php} definition). Finally, note that, \tsobj[value]{html} constructs won't be recognized if they appear inside a \tsobj[value]{php} tagged area (the \tsobj[key]{non tagged} in the \tsobj[value]{html} definition).
  \item \tsobj[value]{SQL,COBOL} both are case insensitive, normalizing the keywords in upper case. This might become relevant in case they get used as the base for an extended \tsobj[marg]{keyset} and used in a case sensitive context. All other case insensitive languages (currently \tsobj[value]{FORTRAN, Ada, html, VB, Delphi}) are normalized using lower case keywords. Why such exception? conventions. Even though they are case insensitive, it's usual to write their commands in upper case. That way, if they get used in a case sensitive context, the convention will hold.
  \item \tsobj[value]{PL/SQL} is defined as alphanumeric, allowing keywords with a \tsfmt{\%}, more precisely, from it's definition: \tsverb{oletter = { \% } }. Note though, that, when expanding the \tsobj[value]{PL/SQL} \tsobj[marg]{keyset} it's mandatory to change the category code of \tsfmt{\%} to other. \tsobj{\hlKeysetDef} absorbs the keywords list as ``other'', therefore \tsobj{\%} is different from \tsfmt{\%}. Better said, if one tries 
      \tsverb{\hlKeysetDef { PL/SQL } { keywd = {2} {SQL\%word}} } instead of \tsverb{\hlKeysetDef { PL/SQL } }\tsfmt{ \{ keywd = \{2\} \{ SQL\%word \} \} } one will end with a keyword \tsverb{SQL\%word} instead of \tsfmt{SQL\%word}. And for the last one, it's necessary to change the category code of a \tsfmt{\%} first.
  \item \TeX{}, there are three language definitions: \tsobj[value]{TeX,TeX.l3,TeX.l3sign}. They are basically the same (usual \LaTeX{} conventions). All three have \tsfmt{\%} denoting a comment line, and an `identifier' named \tsobj[value]{texcs} (more precisely \tsobj[key]{identifier = } \tsverb[value]{ { texcs }   { \\ }  { } }). \tsobj[value]{TeX.l3} declares keywords as being alphanumeric, allowing for an underscore. \tsobj[value]{TeX.l3sign} also declares keywords as alphanumeric, allowing for underscore and a colon to be part of a keyword. These last two are meant to document \tsobj[pkg]{expl3} commands, though it is slightly more efficient to collect a sample code (see \citepkg[Characters Category Code and Common Keys]{codeverbatim}) changing the catcode of these characters (namely underscore and colon) to letter and just use the language definition \tsobj[value]{TeX}.
  \item \tsobj[value]{TeX.primitives} contains all \LaTeXe{} primitives. \tsobj[value]{TeX.pdfTeX} is based on \tsobj[value]{TeX.primitives} adding pdflatex specific ones. \tsobj[value]{TeX.luaTeX} is based on \tsobj[value]{TeX.primitives} adding lualatex specific ones. \tsobj[value]{TeX.common} contains the most common user level, \LaTeXe{}, commands (but no \tsobj[value]{texcs} keywords from the previous sets). Moreover, \tsobj[value]{TeX.pdfTeX,TeX.luaTeX} are the only set the defines \tsobj[value]{texcs} keywords of class 2, all others define sets of class 1 (this allows to easy re-mapping  when using the \tsobj[key]{based on} key (see following example).
  \item The other \tsobj[value]{TeX.} sets were programmatically extracted from the sources.       The many \tsobj[value]{TeX.l3*,TeX.l3*sign} contain \tsobj[pkg]{expl3} valid names, take note that, for instance, \tsobj[value]{TeX.l3ams,TeX.l3amssign} are fundamentally the same, the former containing the `base name' (without the colon and command signature), whilst the last one contains all found commands with respective signatures (those files are large).
  
  They are all separated sets. If one wants to use one (or more) of them together with the previous ones, it is necessary to declare a new \tsobj[marg]{keyset} based on the many ones the reader might want (see \ref{codehl:syntax:basedon} for details). For instance:
      
      
\end{itemize}
      \tscode*[codehl]{demo0X}


%\newpage
%\newgeometry{marginparwidth=10mm,top=20mm,bottom=15mm,hmargin={15mm,15mm},marginparsep=2.5mm,columnsep=10mm,asymmetric}
%
%\AsciiTable{c_str_cctab}
%
%\restoregeometry
%


\section{Examples}

In the following examples, for simplicity, mostly \LaTeXe{} commands are used. Furthermore, they are based on the commands from this package and the ones from \citepkg{codeverbatim}, since this package alone has no provision for grabbing verbatim code.


\input{codehighlight-cmm
}
\printbibliography

\end{document} 