texlive[56210] Master: stricttex (29aug20)

commits+karl at tug.org commits+karl at tug.org
Sat Aug 29 22:17:20 CEST 2020


Revision: 56210
          http://tug.org/svn/texlive?view=revision&revision=56210
Author:   karl
Date:     2020-08-29 22:17:19 +0200 (Sat, 29 Aug 2020)
Log Message:
-----------
stricttex (29aug20)

Modified Paths:
--------------
    trunk/Master/tlpkg/bin/tlpkg-ctan-check
    trunk/Master/tlpkg/libexec/ctan2tds
    trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc

Added Paths:
-----------
    trunk/Master/texmf-dist/doc/lualatex/stricttex/
    trunk/Master/texmf-dist/doc/lualatex/stricttex/README.md
    trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.pdf
    trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.tex
    trunk/Master/texmf-dist/tex/lualatex/stricttex/
    trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.lua
    trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.sty
    trunk/Master/tlpkg/tlpsrc/stricttex.tlpsrc

Added: trunk/Master/texmf-dist/doc/lualatex/stricttex/README.md
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/stricttex/README.md	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/stricttex/README.md	2020-08-29 20:17:19 UTC (rev 56210)
@@ -0,0 +1,34 @@
+stricttex --  strictly balanced brackets and numbers in command names
+--------------------------------------
+
+The stricttex package is a small, LuaLaTeX-only package providing you with
+three, sometimes useful features:
+	* It allows you to make brackets [...] ``strict'', meaning that
+	each [ must be balanced by a ].
+	* It allows you to use numbers in command names, so
+	that you can do stuff like \newcommand\pi12{\pi_{12}}.
+	* It allows you to use numbers \emph{and} primes in command names,
+	so that you can do stuff like \newcommand\pi'12{\pi '_{12}}.
+
+----------------------------------------------------------------
+stricttex --  strictly balanced brackets and numbers in command names
+Version: 0.1beta
+Maintained by Sebastian Ørsted
+E-mail: sorsted at gmail.com
+Released under the LaTeX Project Public License v1.3c or later
+See http://www.latex-project.org/lppl.txt
+----------------------------------------------------------------
+
+Copyright (C) 2020 by Sebastian Ørsted <sorsted at gmail.com>
+
+The package is loaded via \usepackage{leftindex}
+
+This work may be distributed and/or modified under the
+conditions of the LaTeX Project Public License (LPPL), either
+version 1.3c of this license or (at your option) any later
+version.  The latest version of this license is in the file:
+
+http://www.latex-project.org/lppl.txt
+
+This work is "maintained" (as per LPPL maintenance status) by
+Sebastian Ørsted.
\ No newline at end of file


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

Index: trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.pdf
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.pdf	2020-08-29 20:14:35 UTC (rev 56209)
+++ trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.pdf	2020-08-29 20:17:19 UTC (rev 56210)

Property changes on: trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.pdf
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/pdf
\ No newline at end of property
Added: trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.tex
===================================================================
--- trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.tex	                        (rev 0)
+++ trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.tex	2020-08-29 20:17:19 UTC (rev 56210)
@@ -0,0 +1,132 @@
+\documentclass[a4paper,article,oneside,10pt]{memoir}
+
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{babel}
+\usepackage{kpfonts,microtype}
+
+\usepackage{listings,xspace,showexpl}
+
+\usepackage[hidelinks]{hyperref}
+
+\frenchspacing
+
+
+\lstset{
+	language=[LaTeX]TeX,
+	basicstyle=\ttfamily\small,
+	commentstyle=\itshape\ttfamily\small,
+	escapechar=\%,
+	alsoletter={\\,0,1,2,3,4,5,6,7,8,9,'},
+	breaklines=true,
+	breakindent={0pt},
+	captionpos=t,
+	tabsize=2,
+	inputencoding=utf8,
+	extendedchars=true,
+	mathescape=true,
+}
+
+\newcommand\strctttex{\texttt{stricttex}\xspace}
+
+\title{\strctttex\ -- strictly balanced brackets and numbers in command names (v0.1$\beta$)}
+\date{\today}
+\author{Sebastian \O rsted (\href{mailto:sorsted at gmail.com}{sorsted at gmail.com})}
+
+\hypersetup{
+	pdfauthor={Sebastian \O rsted},
+	pdftitle={leftindex -- left indices with better spacing},
+}
+
+\begin{document}
+
+\maketitle
+
+\noindent 
+The \strctttex package is a small, Lua\LaTeX-only package providing you with three, sometimes useful features:
+\begin{itemize}
+	\item It allows you to make brackets \lstinline![...]! ``strict'', meaning that each~`\lstinline![!
+	must be balanced by a~\lstinline!]!.
+	\item It allows you to use numbers in command names, so
+	that you can do stuff like~\lstinline!\newcommand\pi12{\pi_{12}}!.
+	\item It allows you to use numbers \emph{and} primes in command names,
+	so that you can do stuff like~\lstinline!\newcommand\pi'12{\pi '_{12}}!.
+\end{itemize}
+
+\chapter*{Making brackets strict}
+
+The package provides the commands
+\begin{lstlisting}
+\StrictBracketsOn
+\StrictBracketsOff
+\end{lstlisting}
+Between these two commands,
+all left brackets~\lstinline![! are replaced by~\lstinline![$\{$!,
+and all right brackets~\lstinline!]! by~\lstinline!$\}$]!. This forces the brackets to be properly balanced. This is extremely useful in come packages, such as Seman\TeX, where you can then
+do things that would otherwise cause errors, e.g.
+\begin{lstlisting}[mathescape=false]
+\StrictBracketsOn
+	$ \vf[upper=\vx[upper=2,lower=3]] $
+\StrictBracketsOff
+\end{lstlisting}
+Normal brackets can still be accessed by using the standard \TeX\ commands 
+\lstinline!\lbrack! and \lstinline!\rbrack!.
+The replacement algorithm has two important exceptions:
+\begin{itemize}
+	\item \emph{No} replacements apply to the commands~\lstinline!\[...\]!, which can therefore be used as normal.
+	\item If you absolute \emph{need} ordinary brackets,
+	you can write \lstinline!<[>! and~\lstinline!<]>! to access them. This works
+	in all contexts, so e.g. \lstinline!\<[>! and~\lstinline!\<]>! will work
+	just like \lstinline!\[! and~\lstinline!\]!.
+\end{itemize}
+
+\newpage
+
+\chapter*{Allowing numbers (and possibly primes) in commands}
+
+The package provides the commands
+\begin{lstlisting}
+\NumbersInCommandsOn
+\NumbersInCommandsOff
+\NumbersAndPrimesInCommandsOn
+\NumbersAndPrimesInCommandsOff
+\end{lstlisting}
+The first pair of commands allows you to define commands containing numbers. So the following will work:
+\begin{lstlisting}
+\NumbersInCommandsOn
+\newcommand\pi12{\pi_{12}}
+\newcommand\pi13{\pi_{13}}
+\newcommand\pi23{\pi_{23}}
+\newcommand\pi12comma34{\pi_{12,34}}
+\NumbersInCommandsOff
+\end{lstlisting}
+Internally, what happens is that if a command is immediately followed by a number,
+that numbers is replaced by a text string, i.e.
+\lstinline!0!~gets replaced by~\lstinline!numberZERO!,
+\lstinline!1!~gets replaced by~\lstinline!numberONE!,
+etc. These long names have been chosen to prevent name clashes.
+In other words, the code that is eventually passed to \TeX\ is
+\begin{lstlisting}
+\newcommand\pinumberONEnumberTWO{\pi_{12}}
+\newcommand\pinumberONEnumberTHREE{\pi_{13}}
+\newcommand\pinumberTWOnumberTHREE{\pi_{23}}
+\newcommand\pinumberONEnumberTWOcommanumberTHREEnumberFOUR{\pi_{12,34}}
+\end{lstlisting}
+Needless to say, stuff like \lstinline!\kern11pt! will no longer work and will have to be
+replaced by~\lstinline!\kern 11pt!.
+
+The commands \lstinline!\NumbersAndPrimesInCommandsOn! and~\lstinline!\...Off! work almost the same way, except they also allow
+you to use \emph{primes}. So the following will work:
+\begin{lstlisting}
+\NumbersAndPrimesInCommandsOn
+\newcommand\pi'12{\pi '_{12}}
+\NumbersAndPrimesInCommandsOff
+\end{lstlisting}
+Internally, the algorithm works as before, except the prime~\lstinline!'! gets
+replaced by \lstinline!symbolPRIME!. So what is eventually passed to \TeX\ is
+\begin{lstlisting}
+\newcommand\pisymbolPRIMEnumberONEnumberTWO{\pi '_{12}}
+\end{lstlisting}
+
+
+\end{document}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/doc/lualatex/stricttex/stricttex.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.lua
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.lua	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.lua	2020-08-29 20:17:19 UTC (rev 56210)
@@ -0,0 +1,162 @@
+-- Functions for making brackets strict:
+
+stricttexAddBracesToBrackets = function(str)
+	p = str:find('[%[%]]')
+	if p then
+		while true do
+			if str:sub(p-1,p-1) == '\\' then
+				q = str:sub(p+1,-1):find('[%[%]]')
+				if q then
+					p = p + q
+				else
+					break
+				end
+			elseif str:sub(p-1,p+1) == '<[>' or str:sub(p-1,p+1) == '<]>' then
+				str = str:sub(1,p-2) .. str:sub(p,p) .. str:sub(p+2,-1)
+				q = str:sub(p,-1):find('[%[%]]')
+				if q then
+					p = p + q - 1
+				else
+					break
+				end
+			elseif str:sub(p,p) == '[' then
+				str = str:sub(1,p) .. '{' .. str:sub(p+1,-1)
+				q = str:sub(p+2,-1):find('[%[%]]')
+				if q then
+					p = p + q + 1
+				else
+					break
+				end
+			else -- i.e. if str:sub(p,p) == ']'
+				str = str:sub(1,p-1) .. '}' .. str:sub(p,-1)
+				q = str:sub(p+2,-1):find('[%[%]]')
+				if q then
+					p = p + q + 1
+				else
+					break
+				end				
+			end
+		end
+	end
+	return str
+end
+
+stricttexStrictBracketsOn = function()
+	luatexbase.add_to_callback(
+		"process_input_buffer", stricttexAddBracesToBrackets , "stricttexStrictBrackets"
+	)
+	ifStricttexStrictBracketsOn = true
+end
+
+stricttexStrictBracketsOff = function()
+	if ifStricttexStrictBracketsOn then
+		luatexbase.remove_from_callback(
+			"process_input_buffer", "stricttexStrictBrackets"
+		)
+		ifStricttexStrictBracketsOn = false
+	else
+		tex.sprint('\\begingroup\\ExplSyntaxOn\\msg_error:nnnn { stricttex } { callback_not_registered } { \\StrictBracketsOn } { \\StrictBracketsOff }\\endgroup')
+	end
+end
+
+-- Functions for numbers (and possibly primes) in command names
+
+stricttexReplaceNumbersByLetters = function(str)
+	str = str:gsub('0','numberZERO')
+	str = str:gsub('1','numberONE')
+	str = str:gsub('2','numberTWO')
+	str = str:gsub('3','numberTHREE')
+	str = str:gsub('4','numberFOUR')
+	str = str:gsub('5','numberFIVE')
+	str = str:gsub('6','numberSIX')
+	str = str:gsub('7','numberSEVEN')
+	str = str:gsub('8','numberEIGHT')
+	str = str:gsub('9','numberNINE')
+	return str
+end
+
+stricttexFormatNumbers = function(str)
+	local p, q = str:find('\\%a+%d')
+	if p then
+		while true do
+			local r,s = str:sub(q,-1):find('%w+') -- ^ in the beginning did not work
+			local newstring = stricttexReplaceNumbersByLetters( str:sub(q,q+s-1) )
+			local l = string.len(newstring)
+			str = str:sub(1, q-1) .. newstring .. str:sub(q+s,-1)
+			local t = str:sub(q+l,-1):find('\\%a+%d')
+			if t then
+				q = q + l + t - 1
+			else
+				break
+			end
+		end
+	end
+	return str
+end
+
+stricttexReplacePrimes = function(str)
+	str = str:gsub("'",'symbolPRIME')
+	return str
+end
+
+stricttexFormatNumbersAndPrimes = function(str)
+	local p, q = str:find("\\%a+[%d']")
+	if p then
+		while true do
+			local r,s = str:sub(q,-1):find("[%w']+") -- ^ in the beginning did not work
+			local newstring = stricttexReplaceNumbersByLetters( str:sub(q,q+s-1) )
+			mewstring = stricttexReplacePrimes( newstring )
+			local l = string.len(newstring)
+			str = str:sub(1, q-1) .. newstring .. str:sub(q+s,-1)
+			local t = str:sub(q+l,-1):find("\\%a+[%d']")
+			if t then
+				q = q + l + t - 1
+			else
+				break
+			end
+		end
+	end
+	return str
+end
+
+stricttexNumbersInCommandsOn = function()
+	if ifStricttexNumbersAndPrimesInCommands then
+		stricttexNumbersAndPrimesInCommandsOff()
+	end
+	luatexbase.add_to_callback(
+		"process_input_buffer", stricttexFormatNumbers , "stricttexNumbersInCommands"
+	)
+	ifStricttexNumbersInCommands = true
+end
+
+stricttexNumbersInCommandsOff = function()
+	if ifStricttexNumbersInCommands then
+		luatexbase.remove_from_callback(
+			"process_input_buffer", "stricttexNumbersInCommands"
+		)
+		ifStricttexNumbersInCommands = false
+	else
+		tex.sprint('\\begingroup\\ExplSyntaxOn\\msg_error:nnnn { stricttex } { callback_not_registered } { \\NumbersInCommandsOn } { \\NumbersInCommandsOff }\\endgroup')
+	end
+end
+
+stricttexNumbersAndPrimesInCommandsOn = function()
+	if ifStricttexNumbersInCommands then
+		stricttexNumbersInCommandsOff()
+	end
+	luatexbase.add_to_callback(
+		"process_input_buffer", stricttexFormatNumbersAndPrimes , "stricttexNumbersAndPrimesInCommands"
+	)
+	ifStricttexNumbersAndPrimesInCommandsOn = true
+end
+
+stricttexNumbersAndPrimesInCommandsOff = function()
+	if ifStricttexNumbersAndPrimesInCommandsOn then
+		luatexbase.remove_from_callback(
+			"process_input_buffer", "stricttexNumbersAndPrimesInCommands"
+		)
+		ifStricttexNumbersAndPrimesInCommandsOn = false
+	else
+		tex.sprint('\\begingroup\\ExplSyntaxOn\\msg_error:nnnn { stricttex } { callback_not_registered } { \\NumbersAndPrimesInCommandsOn } { \\NumbersAndPrimesInCommandsOff }\\endgroup')
+	end
+end
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.lua
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.sty
===================================================================
--- trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.sty	                        (rev 0)
+++ trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.sty	2020-08-29 20:17:19 UTC (rev 56210)
@@ -0,0 +1,48 @@
+\ProvidesExplPackage{stricttex}{2020/07/28}{0.1beta}{}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%																				%
+%		stricttex -- strictly paired brackets and numbers in command names		%
+%		https://ctan.org/pkg/semantex											%
+%		(C) 2020 Sebastian Ørsted												%
+%       sorsted at gmail.com														%
+%																				%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\msg_new:nnn { stricttex } { not_luatex } { This~package~only~works~with~LuaTeX;~the~current~TeX~run~has~been~terminated. }
+
+\msg_new:nnn { stricttex } { callback_not_registered } { Found~#2 with~no~preceding~#1 }
+
+\sys_if_engine_luatex:F { \msg_fatal:nn { stricttex } { not_luatex } }
+
+\lua_now:e { require('stricttex.lua') }
+
+\cs_new_protected:Npn\StrictBracketsOn
+{
+	\lua_now:e { stricttexStrictBracketsOn() }
+}
+
+\cs_new_protected:Npn\StrictBracketsOff
+{
+	\lua_now:e { stricttexStrictBracketsOff() }
+}
+
+\cs_new_protected:Npn\NumbersInCommandsOn
+{
+	\lua_now:e { stricttexNumbersInCommandsOn() }
+}
+
+\cs_new_protected:Npn\NumbersInCommandsOff
+{
+	\lua_now:e { stricttexNumbersInCommandsOff() }
+}
+
+\cs_new_protected:Npn\NumbersAndPrimesInCommandsOn
+{
+	\lua_now:e { stricttexNumbersAndPrimesInCommandsOn() }
+}
+
+\cs_new_protected:Npn\NumbersAndPrimesInCommandsOff
+{
+	\lua_now:e { stricttexNumbersAndPrimesInCommandsOff() }
+}
\ No newline at end of file


Property changes on: trunk/Master/texmf-dist/tex/lualatex/stricttex/stricttex.sty
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Modified: trunk/Master/tlpkg/bin/tlpkg-ctan-check
===================================================================
--- trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-08-29 20:14:35 UTC (rev 56209)
+++ trunk/Master/tlpkg/bin/tlpkg-ctan-check	2020-08-29 20:17:19 UTC (rev 56210)
@@ -693,7 +693,7 @@
     stdclsdv stdpage stealcaps steinmetz
     stellenbosch step stex
     stickstoo stix stix2-otf stix2-type1 stmaryrd storebox storecmd
-    stringenc stringstrings structmech struktex
+    stricttex stringenc stringstrings structmech struktex
     sttools stubs studenthandouts sty2dtx suanpan
     subdocs subdepth subeqn subeqnarray
     subfig subfigmat subfigure subfiles subfloat substances

Modified: trunk/Master/tlpkg/libexec/ctan2tds
===================================================================
--- trunk/Master/tlpkg/libexec/ctan2tds	2020-08-29 20:14:35 UTC (rev 56209)
+++ trunk/Master/tlpkg/libexec/ctan2tds	2020-08-29 20:17:19 UTC (rev 56210)
@@ -2115,6 +2115,7 @@
  'splitindex',  'splitindex\.tex|' . $standardtex,
  'spotcolor',   'spotcolor.*\.tex|' . $standardtex,
  'startex',     '\.(tex|stx|lan)$',
+ 'stricttex',	'\.lua|' . $standardtex,
  'subfig',      '\.sty|[^c]\.cfg',      # not ltxdoc.cfg, would be system-wide
  'subfigure',   '\.sty|[^c]\.cfg',      # not ltxdoc.cfg, would be system-wide
  'syntax',      'syntax\.tex',

Modified: trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc
===================================================================
--- trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2020-08-29 20:14:35 UTC (rev 56209)
+++ trunk/Master/tlpkg/tlpsrc/collection-luatex.tlpsrc	2020-08-29 20:17:19 UTC (rev 56210)
@@ -55,4 +55,5 @@
 depend plantuml
 depend selnolig
 depend spelling
+depend stricttex
 depend typewriter

Added: trunk/Master/tlpkg/tlpsrc/stricttex.tlpsrc
===================================================================


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