texlive[58408] branches/branch2020.0/Master: highlightlatex (15mar21)

commits+karl at tug.org commits+karl at tug.org
Mon Mar 15 23:14:35 CET 2021


Revision: 58408
          http://tug.org/svn/texlive?view=revision&revision=58408
Author:   karl
Date:     2021-03-15 23:14:35 +0100 (Mon, 15 Mar 2021)
Log Message:
-----------
highlightlatex (15mar21) (branch)

Added Paths:
-----------
    branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/
    branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/LICENSE.txt
    branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/README.md
    branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf
    branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/
    branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/highlightlatex.sty
    branches/branch2020.0/Master/tlpkg/tlpsrc/highlightlatex.tlpsrc

Added: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/LICENSE.txt
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/LICENSE.txt	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/LICENSE.txt	2021-03-15 22:14:35 UTC (rev 58408)
@@ -0,0 +1,21 @@
+MIT License
+
+Copyright (c) 2021 Vincent Kuhlmann
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/LICENSE.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/README.md
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/README.md	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/README.md	2021-03-15 22:14:35 UTC (rev 58408)
@@ -0,0 +1,267 @@
+# Highlight LaTeX: Pretty LaTeX code within LaTeX
+
+Teaching other people LaTeX is great fun, and I've seen plenty of slides and
+readers doing so. You show what you achieve, and how you achieve it. However,
+while the LaTeX you achieve might look splendid, showing code is often done
+using very rudimentary solutions (like plain old verbatim).
+
+They're not to blame: I didn't find pretty colored LaTeX highlighting either. I
+sure want it, and if you're reading this, you probably too, so I've made a
+package for it! It builds further on the generic `listings` package to provide
+colored highlighting for LaTeX. The file `demo.tex` achieves this:
+
+<img src="assets/demoshowoff.png" width="600"
+alt="highlight demo" title="Highlight demo">
+
+## Manual installation
+
+1. Download the `.sty` file, e.g.
+[right click here and select 'save as'](https://github.com/vkuhlmann/highlight-latex/raw/main/highlightlatex.sty).
+2. Copy the file to the directory where your `.tex` file is at...
+3. ... or make it available for all your `.tex` files by placing the file in
+   your TEXMF root.
+
+   **Locating TEXTMF root**
+
+   Note the following default locations:
+
+       MiKTeX on Windows:
+         global installation: C:\Program Files\MiKTeX\tex\latex
+         local installation: %AppData%\..\Local\Programs\MiKTeX\tex\latex
+        
+       TeX Live on Linux or Mac:
+         /usr/share/texmf-texlive/tex/latex
+         /usr/local/texlive/texmf-local/tex/latex
+
+   On Windows you can open a path by pasting the address in the Windows Explorer
+   address bar, or pressing <kbd>Start</kbd>+<kbd>R</kbd> and pasting the
+   address there. One of these directories should contain a long list of
+   packages you have installed. If you can't it, and you use MiKTeX, open MiKTeX
+   Console and open the directories listed under `Settings > Directories` with
+   `Purpose` set to `Install`. Doesn't it exist? Append a `tex` or `latex`
+   directory to the path.
+
+   **Adding the package**
+
+   Add a new directory called `highlightlatex` and place the `.sty` file in it.
+   Then refresh the file name database:
+   * For MiKTeX on Windows open MiKTeX Console and execute `Tasks > Refresh file
+     name database`.
+   * For TeX Live on Linux or Mac, execute in a terminal `sudo texhash`.
+4. Add `\usepackage{highlightlatex}` to your `.tex` file.
+5. For usage of this package, consult the demo files, or read the
+   documentation below.
+
+## Getting started
+
+After having added the package, you can add LaTeX in two ways:
+* Inline style:
+
+      Your file begins with a line of the form \hll|\documentclass[]{}|. The
+      square brackets ...
+
+  The first non-space character following `\hll` is delimits the argument to
+  this command.
+
+* Block style:
+
+      Your basic document now looks like
+      \begin{highlightblock}[gobble=2]
+          \documentclass[a4paper]{article}
+          \begin{document}
+              Hello world!
+          \end{document}
+      \end{highlightblock}
+
+  To prevent indentation of our `highlightblock` (here one tab), to be shown as
+  part of the code, the `gobble` parameters strips them off. Play around with
+  it until everything looks right. I recommend to set this value globally using
+  `\def\defaultgobble{2}`. You can still override that, if necessary.
+
+  There are situations where width of the block could run out of the page. For
+  example, when using beamer and storing a block as described in the section
+  'Fragile breaking situations', the normal full-width of a slide is assumed.
+  If you use multiple columns, set the `linewidth` on the `highlightblock`.
+  This can be a fraction of the total slide width available, `0.6\textwidth`
+  is 60% of the width, or an absolute value, like `10em`, which seems to equal
+  20 characters.
+
+  There are more keys you can provide. Check the
+  [listings package documentation](https://www.ctan.org/pkg/listings) for
+  options available to the `lstlisting`-environment and `lstset` command.
+
+## Adding a command to a highlighting rule
+
+By default, only some LaTeX commands will be highlighted in blue. If there are
+others you need, like `\tableofcontents` and `\figref`, update the highlighting
+rules:
+```
+\updatehighlight{
+	name = default,
+	add = {
+		\tableofcontents, \figref
+	}
+}
+```
+
+The changes will affect only code after it. For a use as this example, I
+recommend putting it in your preamble (before the `\begin{document}`).
+
+## Custom highlighting rules
+
+As shown `demo.tex`, you can put any command or keyword you want to highlight on
+in a different color. You do this with
+```
+\updatehighlight{
+    % A name like 'focus' or 'orange' would be more descriptive,
+    % this is just to show you can make up the name yourself.
+    name = orangejuice,
+    color = orange
+    add = {
+        \tableofcontents
+    }
+}
+```
+
+You can use the `xcolor` syntax for describing colors as well. If you find the
+orange too bright, you can replace it with `orange!90!black`: 90% orange,
+remaining is black. For more information on color definitions and name, refer to
+[LaTeX/Colors on Wikibooks](https://en.wikibooks.org/wiki/LaTeX/Colors).
+
+---
+
+The argument to `\updatehighlight` is a key-value list. Keys are processed
+sequentially. For example, use `color` before rather than after the `add`, and
+a key can appear multiple times. Each one will be processed. You can merge any
+two `\updatehighlight` in one. No need to close and reopen `\updatehighlight`
+for each highlighting rule.
+
+You might be tempted to add a blank line for clarity; that means a new paragraph
+too LaTeX, don't do it. Instead, just put a line with only a `%` sign. Spacing
+within the argument is often irrelevant. If you need a comma in the value,
+surround your value with braces.
+
+The possible keys are:
+* **name**: Create or modify a named rule. This key is optional.
+
+  The default keys are `default`, which includes a bunch of basic commands,
+  and has by default a dark blue color, and `structure`, which consists of
+  `\begin` and `\end` and prints them in light blue.
+
+  _Deprecated alias: label_
+
+* **classoffset**: Set the `listings` classoffset manually. Try to avoid this.
+  Use **name** to refer to existing rules instead.
+
+* **add**: Add a commands (`\mycommand`) oor keywords (`Hi!`) to the current
+  rule. The value can contain multiple values by opening braces, and comma
+  separating values within them.
+
+  _Deprecated aliases: macros (only for commands), commands (only for commands),
+  and keywords (only for keywords)_
+
+* **remove**: Remove a commands or keywords from the current rule. The value can
+  contain multiple values by opening braces, and comma separating values within
+  them.
+
+* **clear**: Remove all commands and keywords from the current rule. Use without
+  value, for example
+
+      \updatehighlight{
+          name = default,
+          clear
+      }
+
+* **color**: Specify a color for the rule. Equivalent to specifying **style**
+  instead, with value `\color{value}` where `value` is the value for the
+  **color** key. So `color=red` and `style=\color{red}` are equivalent.
+
+* **style**: Specify a style for the rule. A rule can only have one style. If
+  you specify a style after `add`, `remove`, `keywords` (deprecated), `macros`
+  (deprecated) or `commands` (deprecated), this starts a new (unnamed) rule.
+  In practice, the only style which will probably work for you is only a color,
+  so just use it instead. But hey, you have the option if you want to. :)
+
+## Global settings
+There are some global parameters involved in the appearance:
+```
+\colorlet{curlyBrackets}{red!50!blue}
+\colorlet{squareBrackets}{blue!50!white}
+\colorlet{codeBackground}{gray!10!white}
+\colorlet{comment}{green!40!black}
+\def\defaultgobble{0}
+```
+
+Each line can be set independent of eachother, and each shows its default value.
+
+There are package options you can use as well:
+* **frame** (default `lines`): specify the frame you want around code. My
+  favorites are `lines` and `none`. Check the
+  [listings package documentation](https://www.ctan.org/pkg/listings) for all
+  possibilities.
+
+* **noframe** (use without value): equivalent to `frame=none`.
+
+* **styleanywhere** (use without value): override the default behavior that
+  `style` starts a new style after commands like `add` and `remove`.
+
+## Fragile breaking situations (like beamer frames)
+
+When passing command arguments around, or storing environment content, LaTeX
+interprets all characters. This includes seeing `\maketitle` in `\hll|\maketitle|`
+as a real command. To prevent this behavior, everything from `\verb`, to the
+`verbatim`-environment, to the `listings` package the highlight LaTeX package
+uses temporarily changes the interpretation of characters that are still to be
+read. The blackslash before maketitle in `\hll|\maketitle|` will be read as
+`just text' (a _letter_ technically).
+
+When content has already been interpreted, like the `frame`-environment in
+`beamer` does, this trick can't be done anymore. Instead, you either need to
+_escape_ code, or _pre-process_ the code outside a fragile breaking situation.
+
+Escaping is done by preceding the special character with a backslash. For
+example, `\hll|\documentclass[]{}|` becomes `\hll|\\documentclass[]\{\}|`.
+
+For large code blocks, this is undesirable. Therefore, the package provides for
+a companion to the `highlightblock`-environment: surround it with a `saveblock`
+environment which takes a single argument: a name to assign it. We use it to
+refer to it later. For example:
+```latex
+\begin{saveblock}{basicfigure}
+    \begin{highlightblock}[linewidth=0.6\textwidth]
+        \begin{figure}
+            \includegraphics
+            [width=0.9\linewidth]
+            {myPlot.pdf}
+            
+            \caption{My plot}
+            \label{fig:myplot}
+        \end{figure}
+    \end{highlightblock}
+\end{saveblock}
+```
+
+Do this outside a fragile breaking situation. (For the `frame`-environment
+example, that means just before the `frame` for example.) Then, where you want
+to use it, use `\useblock{basicfigure}`. There is also a variant
+`\consumeblock{basicfigure}`. If you save many blocks, these will all remain
+loaded in memory till your PDF has fully generated. The `\consumeblock` works
+like `\useblock`, except the saved block is deleted from memory after its use.
+Note this can also result in unexpected behavior, for example animations in a
+beamer frame might need the code line to be executed multiple times. Use
+`\useblock` when you can't make the guarantee this is the last use.
+
+For this special, but very important, situation, I've created a separate demo,
+which you find at `deamerdemo/deamerdemo.tex`.
+
+## Adding extra space
+
+By default, highlight-latex follows an approach where it minimizes spacing.
+This gives you full control over how tight or spacious your document looks.
+Just use commands like `\medskip` to add extra spacing. The package doesn't
+currently include an option to have that done everywhere automatically.
+
+## License
+
+The package is available under MIT License. See LICENSE.txt
+


Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/README.md
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf
===================================================================
(Binary files differ)

Index: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf
===================================================================
--- branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf	2021-03-15 22:14:26 UTC (rev 58407)
+++ branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf	2021-03-15 22:14:35 UTC (rev 58408)

Property changes on: branches/branch2020.0/Master/texmf-dist/doc/latex/highlightlatex/highlightlatex-manual.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/highlightlatex.sty
===================================================================
--- branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/highlightlatex.sty	                        (rev 0)
+++ branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/highlightlatex.sty	2021-03-15 22:14:35 UTC (rev 58408)
@@ -0,0 +1,525 @@
+\NeedsTeXFormat{LaTeX2e}[1994/06/01]
+\ProvidesPackage{highlightlatex}[2021/03/14]
+
+% Repository: https://github.com/vkuhlmann/highlight-latex
+
+% Copyright (c) 2021 Vincent Kuhlmann
+% 
+% Permission is hereby granted, free of charge, to any person
+% obtaining a copy of this software and associated documentation
+% files (the "Software"), to deal in the Software without
+% restriction, including without limitation the rights to use,
+% copy, modify, merge, publish, distribute, sublicense, and/or sell
+% copies of the Software, and to permit persons to whom the
+% Software is furnished to do so, subject to the following
+% conditions:
+% 
+% The above copyright notice and this permission notice shall be
+% included in all copies or substantial portions of the Software.
+% 
+% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+% OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+% NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+% HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+% WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+% FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+% OTHER DEALINGS IN THE SOFTWARE.
+
+\RequirePackage{listings}
+\RequirePackage{xcolor}
+
+\RequirePackage{xkeyval}
+\RequirePackage{etoolbox}
+
+% Snippet source:
+% https://tex.stackexchange.com/questions/406015/defining-macro-gsetlength-as-global-setlength-reliable
+\gdef\gsetlength#1#2{%
+	\begingroup
+		\setlength\skip@{#2}%
+		\global#1=\skip@
+	\endgroup
+}
+
+
+\def\@highlight at frame{none}
+\newlength{\hll at offset@fixskip}
+\setlength{\hll at offset@fixskip}{0pt}
+
+\newif\ifhllStyleAnywhere
+\newcommand\defaultgobble{0}
+\newif\ifhllDebugFrame
+%\hllDebugFrametrue
+\newlength\hllBeforeSkip
+\setlength\hllBeforeSkip{2pt}
+\newlength\hllAfterSkip
+\setlength\hllAfterSkip{0pt}
+
+
+\DeclareOptionX{frame}{
+	\setframe{#1}
+}
+
+\DeclareOptionX{noframe}{
+	\setframe{none}
+}
+
+\def\setframe#1{%
+	\def\frameval{#1}%
+	\ifx\relax#1\relax
+		\def\frameval{lines}%
+	\fi
+	\def\linesvalue{lines}%
+	%
+	\xdef\@highlight at frame{\frameval}%
+	%
+	\ifx\frameval\linesvalue
+		\gsetlength{\hll at offset@fixskip}{6pt}%
+	\else
+		\gsetlength{\hll at offset@fixskip}{0pt}%
+	\fi
+}
+
+\DeclareOptionX{styleanywhere}{
+	\hllStyleAnywheretrue
+}
+
+\DeclareOptionX*{\PackageWarning{highlight-latex}{`\CurrentOption' ignored}}
+\ExecuteOptionsX{frame=lines}
+
+\ProcessOptionsX\relax
+
+\colorlet{curlyBrackets}{red!50!blue}
+\colorlet{squareBrackets}{blue!50!white}
+\colorlet{codeBackground}{gray!10!white}
+\colorlet{comment}{green!40!black}
+
+\colorlet{accDefault}{blue!90!black}
+\definecolor{accStructure}{RGB}{0,149,255}
+
+\colorlet{accentB}{green!60!black}
+
+\catcode`\{=11
+\let\myopenbrace={
+\catcode`\{=1
+
+\catcode`\}=11
+\let\myclosebrace=}
+\catcode`\}=2
+
+\lstdefinelanguage{ColoredLaTeX}
+[LaTeX]{TeX}{
+	backgroundcolor=\color{codeBackground},
+	keywordstyle=\bfseries\color{accDefault},
+	basicstyle=\footnotesize\ttfamily,
+	commentstyle=\color{comment},
+	numbers=none,
+	tabsize=2,
+	mathescape=false,
+	alsoletter={$@_!|?$},
+%
+	classoffset=0,
+	keywordstyle=\color{accDefault},
+	texcsstyle=*\color{accDefault},
+	moretexcs={subsection,thesubsection,thesection,theoremstyle},
+	deletetexcs={begin,end},
+%
+	classoffset=1,
+	keywordstyle=\color{accStructure},
+	texcsstyle=*\color{accStructure},
+	moretexcs={begin,end},
+%
+	classoffset=2,
+	escapeinside=~~,
+%	
+	classoffset=0,
+	%literate={textA}{textB}{3}%
+	%https://tex.stackexchange.com/questions/172945/coloring-in-listing
+	literate={\{}{{\textcolor{curlyBrackets}{\myopenbrace}}}{1}
+		{\}}{{\textcolor{curlyBrackets}{\myclosebrace}}}{1}
+		{[}{{\textcolor{squareBrackets}{[}}}{1}
+		{]}{{\textcolor{squareBrackets}{]}}}{1}%
+	%		{(}{{\textcolor{delimiterColor}{(}}}{1}
+	%		{)}{{\textcolor{delimiterColor}{)}}}{1}%
+	%texcsstyle=\color{blue}
+}
+\lstset{language=ColoredLaTeX}
+
+
+\newcommand{\hllDelimDollar}[1][\color{green!40!black}]{%
+	\lstset{
+		classoffset=2,
+		moredelim=**[s][#1]{$}{$},
+		classoffset=0
+	}%
+}
+
+\newcommand{\hllDelimParen}[1][\color{green!40!black}]{%
+	\lstset{
+		classoffset=2,
+		moredelim=**[s][#1]{\(}{\)},
+		classoffset=0
+	}%
+}
+
+\def\hll at assignlabel#1#2{%
+	\expandafter\gdef\csname hll at labeltoclassoffset@#1\endcsname{#2}%
+}
+
+\hll at assignlabel{default}{0}
+\hll at assignlabel{structure}{1}
+
+
+% =========================
+%   block & inline markup
+% =========================
+
+\newcommand{\hllPrepareBlock}{%
+	\lstset{framesep=0.1cm,framerule=0.6pt}%
+	\def\setHighlightFrame##1{%
+		\lstset{frame=##1}%
+	}%
+	\expandafter\setHighlightFrame\expandafter{\@highlight at frame}%
+	\lstset{belowskip=0pt,aboveskip=0pt,belowcaptionskip=0pt,gobble=\defaultgobble}%
+	\setlength\parskip{0pt}%
+	\setlength\parindent{0pt}%
+}
+
+\lstnewenvironment{highlightblock}[1][]
+{%
+	\vspace{\hllBeforeSkip}%
+	\begingroup
+	\hllPrepareBlock\lstset{#1}%
+}{%
+	\nointerlineskip
+	\endgroup
+	\vspace{\hllAfterSkip}%
+}
+
+\lstnewenvironment{hllblock}[1][]
+{%
+	\vspace{\hllBeforeSkip}%
+	\begingroup
+	\hllPrepareBlock\lstset{#1}%
+}{%
+	\endgroup
+	\vspace{\hllAfterSkip}%
+}
+
+\def\hll{\lstinline}
+
+% ================
+%   block saving
+% ================
+
+\newenvironment{saveblock}[1]{%
+	\expandafter\ifx\csname @codebox@#1\endcsname\relax
+		\expandafter\newbox\csname @codebox@#1\endcsname\relax
+	\fi
+	%
+	% The trick from latex/base/latex.ltx
+	\edef\@bracehack{%
+		\endgroup
+		\expandafter\setbox\csname @codebox@#1\endcsname\vbox{%
+			\begingroup\aftergroup}%
+		\def\noexpand\@currenvir{\@currenvir}%
+		\def\noexpand\@currenvline{\on at line}}%
+	\@bracehack
+	\begingroup\vspace{\hll at offset@fixskip}
+	\ignorespaces%
+}{%
+	\endgroup
+}
+
+\newcommand\useblock[1]{%
+	\ifhllDebugFrame
+		\par
+		{%
+			\setlength{\fboxsep}{0pt}%
+			\fcolorbox{orange}{red}{\expandafter\usebox\csname @codebox@#1\endcsname}%
+		}%
+		\par
+	\else
+		\par\expandafter\usebox\csname @codebox@#1\endcsname\par
+	\fi
+}
+
+\newcommand\consumeblock[1]{%
+	\ifhllDebugFrame
+		\par
+		{%
+			\setlength{\fboxsep}{0pt}%
+			\setlength{\fboxrule}{1pt}%
+			\fcolorbox{orange}{red}{\leavevmode\expandafter\box\csname @codebox@#1\endcsname\relax}%
+		}
+		\par
+		\expandafter\let\csname @codebox@#1\endcsname\relax
+	\else
+		\par\leavevmode\expandafter\box\csname @codebox@#1\endcsname\relax\par
+		\expandafter\let\csname @codebox@#1\endcsname\relax
+	\fi
+}
+
+% ===================
+%   updatehighlight
+% ===================
+
+\def\hll at update@label{}
+
+\newcounter{hll at update@state}
+
+\newcounter{hll at update@nextclassoffset}
+\setcounter{hll at update@nextclassoffset}{5}
+
+\newcounter{hll at update@classoffset}
+
+\def\hll at update@fixclassoffset{%
+	\ifnum\value{hll at update@state}<1\relax
+	\setcounter{hll at update@classoffset}{\thehll at update@nextclassoffset}%
+	\stepcounter{hll at update@nextclassoffset}%
+	\setcounter{hll at update@state}{1}%
+	\fi
+}
+
+\newcommand{\updatehighlight}[1]{%
+	\setcounter{hll at update@state}{-1}%
+	\gdef\hll at update@label{}%
+	\setkeys{updatehighlight}{#1}%
+	%
+	\lstset{classoffset=0}%
+}
+
+
+%%% KEY: label
+%%% ----------
+
+\define at key{updatehighlight}{label}{%
+	\hll at update@setlabel{#1}%
+}
+
+\define at key{updatehighlight}{name}{%
+	\hll at update@setlabel{#1}%
+}
+
+\def\hll at update@setlabel#1{
+	\gdef\hll at update@label{#1}%
+	\expandafter\def\expandafter\@capturedlabel\expandafter{\csname hll at labeltoclassoffset@#1\endcsname}%
+	\expandafter\unless\expandafter\ifx\@capturedlabel\relax\relax
+		% Label exists
+		\edef\@val{\@capturedlabel}%
+		\setcounter{hll at update@classoffset}{\@val}%
+		\setcounter{hll at update@state}{1}%
+	\else
+		% Allocate new label
+		\edef\@val{\thehll at update@nextclassoffset}%
+		\setcounter{hll at update@classoffset}{\@val}%
+		\stepcounter{hll at update@nextclassoffset}%
+		\setcounter{hll at update@state}{1}%
+		%
+		\expandafter\xdef\@capturedlabel{\@val}%
+	\fi
+}
+
+%%% KEY: classoffset
+%%% ----------------
+
+\define at key{updatehighlight}{classoffset}{%
+	\setcounter{hll at update@classoffset}{#1}%
+	\setcounter{hll at update@state}{1}%
+}
+
+%%% KEY: commands
+%%% -------------
+
+\define at key{updatehighlight}{macros}{%
+	\hll at update@macros{#1}%
+}
+
+\define at key{updatehighlight}{commands}{%
+	\hll at update@macros{#1}%
+}
+
+
+\def\hll at update@macros#1{%
+	\hll at update@fixclassoffset
+	\def\@inv##1{\forcsvlist{\hll at update@addmacro{##1}}{#1}}%
+	\expandafter\@inv\expandafter{\the\c at hll@update at classoffset}
+	%
+	\setcounter{hll at update@state}{2}%
+}
+
+\def\hll at update@addmacro#1#2{%
+	\if\noexpand#2\relax
+		\edef\keywordpure{\expandafter\@gobble\string#2}%
+		\def\callwithpure##1{\hll at update@addmacro at i{#1}{##1}}%
+	\expandafter\callwithpure\expandafter{\keywordpure}%
+	\else
+		\hll at update@addmacro at i{#1}{#2}%
+	\fi
+}
+
+\def\hll at update@addmacro at i#1#2{%
+	\lstset{
+		classoffset=0,deletetexcs={#2},
+		classoffset=1,deletetexcs={#2},
+		classoffset=#1,moretexcs={#2},
+		classoffset=0
+	}%
+}
+
+
+%%% KEY: add
+%%% --------
+
+\define at key{updatehighlight}{add}{%
+	\hll at update@add{#1}%
+}
+
+\def\hll at update@add#1{%
+	\hll at update@fixclassoffset
+	\def\@inv##1{\forcsvlist{\hll at update@additem{##1}}{#1}}%
+	\expandafter\@inv\expandafter{\the\c at hll@update at classoffset}
+	%
+	\setcounter{hll at update@state}{2}%
+}
+
+\def\hll at update@additem#1#2{%
+	\if\noexpand#2\relax
+		\edef\keywordpure{\expandafter\@gobble\string#2}%
+		\def\callwithpure##1{\hll at update@addmacro at i{#1}{##1}}%
+		\expandafter\callwithpure\expandafter{\keywordpure}%
+	\else
+		\hll at update@addkeyword{#1}{#2}%
+	\fi
+}
+
+%%% KEY: remove
+%%% -----------
+
+\define at key{updatehighlight}{remove}{%
+	\hll at update@remove{#1}%
+}
+
+\def\hll at update@remove#1{%
+	\hll at update@fixclassoffset
+	\def\@inv##1{\forcsvlist{\hll at update@removeitem{##1}}{#1}}%
+	\expandafter\@inv\expandafter{\the\c at hll@update at classoffset}
+	%
+	\setcounter{hll at update@state}{2}%
+}
+
+\def\hll at update@removeitem#1#2{%
+	\if\noexpand#2\relax
+		\edef\keywordpure{\expandafter\@gobble\string#2}%
+		\def\callwithpure##1{\hll at update@removemacro{#1}{##1}}%
+		\expandafter\callwithpure\expandafter{\keywordpure}%
+	\else
+		\hll at update@removekeyword{#1}{#2}%
+	\fi
+}
+
+\def\hll at update@removemacro#1#2{%
+	\lstset{
+		classoffset={#1},
+		deletetexcs={#2}
+	}%
+}
+
+\def\hll at update@removekeyword#1#2{%
+	\lstset{
+		classoffset={#1},
+		deletekeywords={#2}
+	}%
+}
+
+
+%%% KEY: keywords
+%%% -------------
+
+\define at key{updatehighlight}{keywords}{%
+	\hll at update@keywords{#1}%
+}
+
+
+\def\hll at update@keywords#1{%
+	\hll at update@fixclassoffset
+	\def\@inv##1{\forcsvlist{\hll at update@addkeyword{##1}}{#1}}%
+	\expandafter\@inv\expandafter{\the\c at hll@update at classoffset}%
+	%
+	\setcounter{hll at update@state}{2}%
+}
+
+\def\hll at update@addkeyword#1#2{%
+	\lstset{
+		classoffset=0,deletekeywords={#2},
+		classoffset=1,deletekeywords={#2},
+		classoffset=#1,otherkeywords={#2},morekeywords={#2},
+		classoffset=0
+	}%
+}
+
+
+%%% KEY: style
+%%% ----------
+
+\define at key{updatehighlight}{style}{%
+	\hll at update@fixclassoffset
+	\unless\ifhllStyleAnywhere
+		\ifnum\value{hll at update@state}>1\relax
+			\setcounter{hll at update@state}{0}%
+			\hll at update@fixclassoffset
+		\fi
+	\fi
+	%
+	\expandafter\hll at update@setstyle\expandafter{\the\c at hll@update at classoffset}{#1}%
+}
+
+\def\hll at update@setstyle#1#2{%
+	\lstset{%
+		classoffset=#1,
+		keywordstyle={#2},
+		texcsstyle={*#2},
+	}%
+}
+
+%%% KEY: color
+%%% ----------
+
+\define at key{updatehighlight}{color}{%
+	\hll at update@fixclassoffset
+	\unless\ifhllStyleAnywhere
+		\ifnum\value{hll at update@state}>1\relax
+			\setcounter{hll at update@state}{0}%
+			\hll at update@fixclassoffset
+		\fi
+	\fi
+	%
+	\expandafter\hll at update@setcolor\expandafter{\the\c at hll@update at classoffset}{#1}%
+}
+
+\def\hll at update@setcolor#1#2{%
+	\lstset{%
+		classoffset=#1,
+		keywordstyle={\color{#2}},
+		texcsstyle={*\color{#2}},
+	}%
+}
+
+%%% KEY: clear
+%%% ----------
+
+\define at key{updatehighlight}{clear}[]{%
+	\hll at update@fixclassoffset
+	\expandafter\hll at update@clear\expandafter{\the\c at hll@update at classoffset}%
+}
+
+\def\hll at update@clear#1{%
+	\lstset{
+		classoffset=#1,
+		texcs={},
+		keywords={},
+		classoffset=0
+	}%
+}
+
+


Property changes on: branches/branch2020.0/Master/texmf-dist/tex/latex/highlightlatex/highlightlatex.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: branches/branch2020.0/Master/tlpkg/tlpsrc/highlightlatex.tlpsrc
===================================================================


More information about the tex-live-commits mailing list.