summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/semantex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-09-09 03:03:16 +0000
committerNorbert Preining <norbert@preining.info>2020-09-09 03:03:16 +0000
commit4b315627efc5a6beb1e6c6ec7a98779f215c75eb (patch)
treecf65539a3758192b9bfbaea63d1962f28ec32a3e /macros/latex/contrib/semantex
parentbc2d0660f4f460b55009ab4e525f2a0e4cde6187 (diff)
CTAN sync 202009090303
Diffstat (limited to 'macros/latex/contrib/semantex')
-rw-r--r--macros/latex/contrib/semantex/semantex.pdfbin359130 -> 359206 bytes
-rw-r--r--macros/latex/contrib/semantex/semantex.sty2
-rw-r--r--macros/latex/contrib/semantex/semantex.tex8
-rw-r--r--macros/latex/contrib/semantex/semtex.sty83
-rw-r--r--macros/latex/contrib/semantex/stripsemantex.lua38
-rw-r--r--macros/latex/contrib/semantex/stripsemantex.sty14
6 files changed, 136 insertions, 9 deletions
diff --git a/macros/latex/contrib/semantex/semantex.pdf b/macros/latex/contrib/semantex/semantex.pdf
index 860064bf45..7fc0a4927a 100644
--- a/macros/latex/contrib/semantex/semantex.pdf
+++ b/macros/latex/contrib/semantex/semantex.pdf
Binary files differ
diff --git a/macros/latex/contrib/semantex/semantex.sty b/macros/latex/contrib/semantex/semantex.sty
index c2ca6e552b..2da252301b 100644
--- a/macros/latex/contrib/semantex/semantex.sty
+++ b/macros/latex/contrib/semantex/semantex.sty
@@ -1,5 +1,5 @@
\RequirePackage{xparse,l3keys2e,semtex,leftindex}
-\ProvidesExplPackage{semantex}{2020/09/07}{0.4beta}{}
+\ProvidesExplPackage{semantex}{2020/09/08}{0.41beta}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
diff --git a/macros/latex/contrib/semantex/semantex.tex b/macros/latex/contrib/semantex/semantex.tex
index 81064afc8e..ca5f0cc8be 100644
--- a/macros/latex/contrib/semantex/semantex.tex
+++ b/macros/latex/contrib/semantex/semantex.tex
@@ -38,7 +38,7 @@
\usepackage[nameinlink]{cleveref}
-\title{Seman\!\TeX: semantic, keyval-based mathematics (v$0.4\beta$)}
+\title{Seman\!\TeX: semantic, keyval-based mathematics (v$0.41\beta$)}
\date{\today}
\author{Sebastian Ørsted (\href{mailto:sorsted@gmail.com}{sorsted@gmail.com})}
@@ -3302,7 +3302,7 @@ In the following sections, we include the full list.
\item
\mylst!intclear={$\<integer\>$}!
- Clears the \<integer\>.
+ Clears the \<integer\>, i.e.~sets it to~\( 0 \).
\item
\mylst!ifblankTF={$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\
@@ -5228,7 +5228,7 @@ These are the predefined keys that work inside the argument.
\section{The programming commands}\label{sec:programming_commands}
-The following commands are available for programming inside \lstinline!execute={...}!:
+The following commands are available for programming inside keys, including \lstinline!execute={...}!:
\begin{itemize}
\item
@@ -5435,7 +5435,7 @@ The following commands are available for programming inside \lstinline!execute={
\item
\mylst!\SemantexIntClear{$\<integer\>$}!
- Clears the \<integer\>.
+ Clears the \<integer\>, i.e.~sets it to~\( 0 \).
\item
\mylst!\SemantexIfBlankTF{$\<tokens\>$}{$\<if true\>$}{$\<if false\>$}!,\\
diff --git a/macros/latex/contrib/semantex/semtex.sty b/macros/latex/contrib/semantex/semtex.sty
new file mode 100644
index 0000000000..3b9196c361
--- /dev/null
+++ b/macros/latex/contrib/semantex/semtex.sty
@@ -0,0 +1,83 @@
+\RequirePackage{xparse}
+\ProvidesExplPackage{semtex}{2020/07/29}{0.1beta}{}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% semtex -- for documents stripped of SemanTeX markup %
+% https://ctan.org/pkg/semantex %
+% (C) 2020 Sebastian Ørsted %
+% sorsted@gmail.com %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+% Bullets:
+
+\box_new:N \g__semantex_bullet_box
+\hbox_set:Nn \g__semantex_bullet_box { $\cdot$ }
+\box_scale:Nnn \g__semantex_bullet_box {1.2} {1.2}
+\tl_set:Nn\g_semantex_bullet
+{
+ \box_move_up:nn{-0.25ex}{\box_use:N \g__semantex_bullet_box}
+}
+
+\tl_set:Nn\g_semantex_double_bullet{\g_semantex_bullet \g_semantex_bullet}
+
+\tl_set_eq:NN\SemantexBullet \g_semantex_bullet
+
+\tl_set_eq:NN \SemantexDoubleBullet \g_semantex_double_bullet
+
+
+% Parentheses:
+
+\cs_new:Npn\SemantexLeft { \mathopen{}\mathclose\bgroup\left }
+
+\cs_new:Npn\SemantexRight { \aftergroup\egroup\right }
+
+\tl_new:N\SemantexDelimiterSize
+
+\DeclareDocumentCommand\SemantexParentheses { mmmm }
+{
+ \str_case:nnF { #1 } % This is where \big,\Big, etc. go.
+ {
+ { normal } {
+ \group_begin:
+ \tl_clear:N \SemantexDelimiterSize
+ \str_if_eq:nnF { #2 } { . } { \mathopen #2 }
+ #4
+ \str_if_eq:nnF { #3 } { . } { \mathclose #3 }
+ \group_end:
+ }
+ { auto } {
+ \group_begin:
+ \tl_set_eq:NN \SemantexDelimiterSize \middle
+ \SemantexLeft #2
+ #4
+ \SemantexRight #3
+ \group_end:
+ }
+ { * } {
+ \group_begin:
+ \tl_set_eq:NN \SemantexDelimiterSize \middle
+ \SemantexLeft #2
+ #4
+ \SemantexRight #3
+ \group_end:
+ }
+ }
+ {
+ \group_begin:
+ \tl_set_eq:NN\SemantexDelimiterSize #1
+ \mathopen #1 #2
+ #4
+ \mathclose #1 #3
+ \group_end:
+ }
+}
+
+\DeclareDocumentCommand\SemantexNoParentheses { m }
+{
+ \group_begin:
+ \tl_clear:N\SemantexDelimiterSize
+ #1
+ \group_end:
+} \ No newline at end of file
diff --git a/macros/latex/contrib/semantex/stripsemantex.lua b/macros/latex/contrib/semantex/stripsemantex.lua
index 769d5b0551..ba3eb9f2da 100644
--- a/macros/latex/contrib/semantex/stripsemantex.lua
+++ b/macros/latex/contrib/semantex/stripsemantex.lua
@@ -55,7 +55,12 @@ end
addIDsToRegisters = function(str)
str = removeStricttexFormatting(str)
- content = content:gsub('\\' .. str .. '%f[^%a]' ,'\\SemantexIDcommand{}\\' .. str)
+ content = content:gsub('\\' .. str .. '([^%a])' ,'\\SemantexIDcommand{}\\' .. str .. '%1')
+ -- '%f[^%a]' does not work here, as it will not react if the last character of str is a number,
+ -- which stricttex allows.
+ -- Because of this choice, there will be an issue if you use stricttex and let
+ -- \<command> by a SemanTeX command and \<command>' be a non-SemanTeX command.
+ -- So simply *don't do that*.
end
removeSuperfluousIDs = function()
@@ -106,7 +111,7 @@ semantexIDluacommand = function(id, source, output)
content = content:sub(1 , p-1) .. content:sub(p+1, -1)
i = i + 1
elseif s:match('%s') then
- content = content:sub(1, p-1) .. content:sub (p+1, -1)
+ content = content:sub(1, p-1) .. content:sub(p+1, -1)
elseif s == '%' then
content = content:sub(1 , p-1) .. content:sub(p,-1):gsub('%%.-\n','',1)
elseif s == '{' then
@@ -123,9 +128,38 @@ semantexIDluacommand = function(id, source, output)
netto = netto + 1
elseif e == '\\' then
q = q + 1
+ elseif e == '%' then
+ content = content:sub(1, p+q-1) .. content:sub(p+q,-1):gsub('%%.-\n','',1)
+ q = q - 1
end
end
content = content:sub(1,p-1) .. content:sub(p+1,p+q-1) .. content:sub(p+q+1,-1)
+ elseif s == '<' and content:sub(p+1,p+2) == '[>' then
+ content = content:sub(1,p-1) .. content:sub(p+3,-1)
+ i = i + 1
+ elseif s == '<' and content:sub(p+1,p+2) == ']>' then
+ content = content:sub(1,p-1) .. content:sub(p+3,-1)
+ i = i + 1
+ elseif source:sub(i,i) == '{' then
+ -- In this case, we remove the corresponding right brace,
+ -- once we find it
+ local netto = 1 -- The current brace group level
+ local q = 0 -- The position we have moved forward so far
+ while netto > 0 do
+ q = q + 1
+ local e = source:sub(i+q,i+q)
+ if e == '}' then
+ netto = netto - 1
+ elseif e == '{' then
+ netto = netto + 1
+ elseif e == '\\' then
+ q = q + 1
+ -- there is no chance that the source contains a %, so we do not
+ -- check for this
+ end
+ end
+ source = source:sub(1,i-1) .. source:sub(i+1,i+q-1) .. source:sub(i+q+1,-1)
+ length = source:len()
else
tex.sprint( [[\begingroup\ExplSyntaxOn
\msg_fatal:nnnn { stripsemantex } { source_not_expected } { ]] .. source:sub(i,i) .. [[ } { ]] .. s .. [[ }
diff --git a/macros/latex/contrib/semantex/stripsemantex.sty b/macros/latex/contrib/semantex/stripsemantex.sty
index eba5638624..96c40fdb87 100644
--- a/macros/latex/contrib/semantex/stripsemantex.sty
+++ b/macros/latex/contrib/semantex/stripsemantex.sty
@@ -1,4 +1,5 @@
-\ProvidesExplPackage{stripsemantex}{2020/09/07}{0.1alpha}{}
+\RequirePackage{xparse}
+\ProvidesExplPackage{stripsemantex}{2020/09/05}{0.1alpha}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
@@ -66,7 +67,16 @@
openFile('\lua_escape:e{#1}_stripped.tex')
}
- \cs_set:Npn\SemantexID##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput
+ \DeclareDocumentCommand\SemantexID{ m t{\BeginSource} }
+ {
+ \IfBooleanT{##2}
+ {
+ \strip_semantex_id_command:w ##1 \BeginSource
+ }
+ }
+
+
+ \cs_set:Npn\strip_semantex_id_command:w##1\BeginSource##2\EndSource\BeginOutput##3\EndOutput
{
\lua_now:e
{